Flying Goose WiFi Printer configuration, PHP call interface

Source: Internet
Author: User
Tags ukey

Download the corresponding documentation from the Flying Goose Printer website http://www.feieyun.cn/api.php. Here's An example of PHP

After downloading, the directory is as Follows:




This is the official packaging of the printer class, no special needs, do not need to change the method Inside.

HttpClient.class.php



In this file is written to call the method of the printer, stitching needs to print the character content, the inside of the method, according to the need to make the corresponding changes:
<?PHPHeader("content-type:text/html; Charset=utf-8 ");include' HttpClient.class.php ';Define(' USER ', ' xxxxxxxxxxxxx ');//* User fill in *: Flying Goose Cloud background registered accountDefine(' ukey ', ' xxxxxxxxxxxxx ');//* User fill in *: ukey//api URL generated after flying Goose cloud registered accountDefine(' IP ', ' api.feieyun.cn ');//interface IP or domain nameDefine(' PORT ', 80);//Interface IP PortDefine(' HOSTNAME ', '/api/open/');//Interface PathDefine(' stime ', time());//public parameters, Request TimeDefine(' SIG ',SHA1(USER. Ukey. stime));//Public parameters, Request Public key//================== Method 1. Print Order ==================//*** interface return value description * *//correct example: {"msg": "ok", "ret": 0, "data ":" 316500004_20160823165104_1853029628 "," serverexecutedtime ": 6}//error: {" msg ":" error message. "," ret ": not 0 error code," data ": null," Serverexecutedtime ": 5}//label description://" <BR> "for line break//" <CUT> "for cutter Instruction (active paper cutting, only Limit knife printer Use only effect)//"<LOGO>" for printing logo instructions (if pre-built in the machine logo image)//"<PLUGIN>" for the cash drawer or external audio command//"<CB> </CB> "for center//" <B></B> to zoom in//"<C></C>" center//"<L></L>" for font change        High one times//"<W></W>" for font width of one//"<QR></QR>" for QR code//"<RIGHT></RIGHT>" for right alignment When piecing together the order content, you can refer to the following format//adjust the format of the content according to the width of the printed paper, refer to the following sample format        $orderInfo= ' <CB> test print </CB><BR> '; $orderInfo. = ' Name Unit Price quantity amount <BR> '; $orderInfo. = '--------------------------------<BR> '; $orderInfo. = ' Rice 10.0 10.0<br> '; $orderInfo. = ' Fried Rice 10.0 Ten 10.0<br> '; $orderInfo. = ' Egg Fried Rice 10.0 100.0<br> '; $orderInfo. = ' Egg Fried rice 100.0 100.0<br> '; $orderInfo. = ' Tomato fried rice 1000.0 1 100.0<br> '; $orderInfo. = ' tomato egg fried rice 100.0 100.0<br> '; $orderInfo. = ' tomato egg Fried rice 15.0 1 15.0<br> '; $orderInfo. = ' remark: add spicy <BR> '; $orderInfo. = '--------------------------------<BR> '; $orderInfo. = ' Total: xx.0 $ <BR> '; $orderInfo. = ' Delivery location: Guangzhou, xx road, nan Sandy area, xx <BR> '; $orderInfo. = ' Contact phone:13888888888888<br> '; $orderInfo. = ' Order time: 2014-08-08 08:08:08<br> '; $orderInfo. = ' <QR>http://www.dzist.com</QR> ';//The QR code string can be automatically generated QR code//open note to test the//wp_print ("printer number", $orderInfo, 1); =========== Method 2. Query Whether an order is printed successfully =============//*** interface return value description * *//correct example://has been printed: {"msg": "ok", "ret": 0, "data": TR        ue, "serverexecutedtime": 6}//not printed: {"msg": "ok", "ret": 0, "data": false, "serverexecutedtime": 6}//open comment to test                    $orderindex = "xxxxxxxxxxxxxx";//order index, get//queryorderstate ($orderindex) from the return value of method 1; =========== Method 3. Query The order details for a specified printer day ============//*** interface return value description * *//correct example: {"msg": "ok", "ret": 0, "data": {"print": 6, "wa Iting ": 1}," serverexecutedtime ": 9}//open comment to test//$sn =" xxxxxxxxx ";//printer number//$date =" 2016-08-27        ";//note the time format is" yyyy-mm-dd ", such as 2016-08-27//queryorderinfobydate ($sn, $date); =========== Method 4. Query The status of the printer ==========================//*** interface return value description * *//correct example://{"msg": "ok", "ret": 0, "da Ta ":" offline "," serverexecutedtime ": 9}//{" msg ":" OK "," ret ": 0," data ":" online, working status isRegular "," serverexecutedtime ": 9}//{" msg ":" OK "," ret ": 0," data ":" online, working unhealthy "," serverexecutedtime ": 9}//open comments can be Test//queryprinterstatus ("printer number");/** Method 1 when piecing together the contents of the order can refer to the following format according to the width of the printed paper, adjust the format of the content, you can refer to the following sample format*/functionWp_print ($printer _SN,$orderInfo,$times){            $content=Array(                        ' User ' =>user, ' stime ' =>stime, ' sig ' =>sig, ' apiname ' = ' open_printmsg ', ' SN ' =$printer _SN, ' content ' =$orderInfo, ' Times ' =$times//Print Count        ); $client=NewHttpClient (IP,PORT); if(!$client->post (HOSTNAME,$content)){        Echo' Error '; }    Else{        Echo $client-getcontent (); }    }/** Method 2 according to the order index, to inquire whether the order is printed successfully, The order index is returned by Method 1*/functionQueryorderstate ($index){        $msgInfo=Array(            ' User ' =>user, ' stime ' =>stime, ' sig ' =>sig, ' apiname ' = ' Open_queryordersta ' Te ', ' orderid ' =$index        ); $client=NewHttpClient (IP,PORT); if(!$client->post (HOSTNAME,$msgInfo)){        Echo' Error '; }    Else{        $result=$client-getcontent (); Echo $result; }    }/** Method 3 Query The specified printer one day Order Details*/functionQueryorderinfobydate ($printer _SN,$date){        $msgInfo=Array(            ' User ' =>user, ' stime ' =>stime, ' sig ' =>sig, ' apiname ' = ' open_queryo ' Rderinfobydate ', ' sn ' = =$printer _SN, ' Date ' =$date        ); $client=NewHttpClient (IP,PORT); if(!$client->post (HOSTNAME,$msgInfo)){         Echo' Error '; }    Else{        $result=$client-getcontent (); Echo $result; }    }/** Method 4 Query the status of the print machine*/functionQueryprinterstatus ($printer _SN){                $msgInfo=Array(            ' User ' =>user, ' stime ' =>stime, ' sig ' =>sig, ' debug ' = ' Nojson ', ' Apiname ' = ' open_queryprinterstatus ', ' sn ' = =$printer _SN        ); $client=NewHttpClient (IP,PORT); if(!$client->post (HOSTNAME,$msgInfo)){        Echo' Error '; }    Else{        $result=$client-getcontent (); Echo $result; }}?>

The constants in the above method can be obtained after registration

Define (' USER ', ' xxxxxxxxxxxxx ');   * User fill in *: Flying Goose Cloud Background registered account
Define (' ukey ', ' xxxxxxxxxxxxx '); * User fill in *: Flying Goose Cloud registered account after the creation of Ukey
Such as:



This article is for individual originality, hope can facilitate oneself, benefit Others.

Flying Goose WiFi Printer configuration, PHP call interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.