1、下載他的基類、并添加上命名空間、改一下類名和文件名

下面封裝的方法有打印小票、添加打印機、刪除打印機
```
<?php
namespace feieyun;
class HttpClient {
// Request vars
var $host;
var $port;
var $path;
var $method;
var $postdata = '';
var $cookies = array();
var $referer;
var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*';
var $accept_encoding = 'gzip';
var $accept_language = 'en-us';
var $user_agent = 'Incutio HttpClient v0.9';
var $timeout = 20;
var $use_gzip = true;
var $persist_cookies = true;
var $persist_referers = true;
var $debug = false;
var $handle_redirects = true;
var $max_redirects = 5;
var $headers_only = false;
var $username;
var $password;
var $status;
var $headers = array();
var $content = '';
var $errormsg;
var $redirect_count = 0;
var $cookie_host = '';
function __construct($host, $port=80) {
$this->host = $host;
$this->port = $port;
}
function get($path, $data = false) {
$this->path = $path;
$this->method = 'GET';
if ($data) {
$this->path .= '?'.$this->buildQueryString($data);
}
return $this->doRequest();
}
function post($path, $data) {
$this->path = $path;
$this->method = 'POST';
$this->postdata = $this->buildQueryString($data);
return $this->doRequest();
}
function buildQueryString($data) {
$querystring = '';
if (is_array($data)) {
foreach ($data as $key => $val) {
if (is_array($val)) {
foreach ($val as $val2) {
$querystring .= urlencode($key).'='.urlencode($val2).'&';
}
} else {
$querystring .= urlencode($key).'='.urlencode($val).'&';
}
}
$querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
} else {
$querystring = $data;
}
return $querystring;
}
function doRequest() {
if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {
switch($errno) {
case -3:
$this->errormsg = 'Socket creation failed (-3)';
case -4:
$this->errormsg = 'DNS lookup failure (-4)';
case -5:
$this->errormsg = 'Connection refused or timed out (-5)';
default:
$this->errormsg = 'Connection failed ('.$errno.')';
$this->errormsg .= ' '.$errstr;
$this->debug($this->errormsg);
}
return false;
}
socket_set_timeout($fp, $this->timeout);
$request = $this->buildRequest();
$this->debug('Request', $request);
fwrite($fp, $request);
$this->headers = array();
$this->content = '';
$this->errormsg = '';
$inHeaders = true;
$atStart = true;
while (!feof($fp)) {
$line = fgets($fp, 4096);
if ($atStart) {
$atStart = false;
if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
$this->errormsg = "Status code line invalid: ".htmlentities($line);
$this->debug($this->errormsg);
return false;
}
$http_version = $m[1];
$this->status = $m[2];
$status_string = $m[3];
$this->debug(trim($line));
continue;
}
if ($inHeaders) {
if (trim($line) == '') {
$inHeaders = false;
$this->debug('Received Headers', $this->headers);
if ($this->headers_only) {
break;
}
continue;
}
if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
continue;
}
$key = strtolower(trim($m[1]));
$val = trim($m[2]);
if (isset($this->headers[$key])) {
if (is_array($this->headers[$key])) {
$this->headers[$key][] = $val;
} else {
$this->headers[$key] = array($this->headers[$key], $val);
}
} else {
$this->headers[$key] = $val;
}
continue;
}
$this->content .= $line;
}
fclose($fp);
if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') {
$this->debug('Content is gzip encoded, unzipping it');
$this->content = substr($this->content, 10);
$this->content = gzinflate($this->content);
}
if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) {
$cookies = $this->headers['set-cookie'];
if (!is_array($cookies)) {
$cookies = array($cookies);
}
foreach ($cookies as $cookie) {
if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
$this->cookies[$m[1]] = $m[2];
}
}
$this->cookie_host = $this->host;
}
if ($this->persist_referers) {
$this->debug('Persisting referer: '.$this->getRequestURL());
$this->referer = $this->getRequestURL();
}
if ($this->handle_redirects) {
if (++$this->redirect_count >= $this->max_redirects) {
$this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')';
$this->debug($this->errormsg);
$this->redirect_count = 0;
return false;
}
$location = isset($this->headers['location']) ? $this->headers['location'] : '';
$uri = isset($this->headers['uri']) ? $this->headers['uri'] : '';
if ($location || $uri) {
$url = parse_url($location.$uri);
return $this->get($url['path']);
}
}
return true;
}
function buildRequest() {
$headers = array();
$headers[] = "{$this->method} {$this->path} HTTP/1.0";
$headers[] = "Host: {$this->host}";
$headers[] = "User-Agent: {$this->user_agent}";
$headers[] = "Accept: {$this->accept}";
if ($this->use_gzip) {
$headers[] = "Accept-encoding: {$this->accept_encoding}";
}
$headers[] = "Accept-language: {$this->accept_language}";
if ($this->referer) {
$headers[] = "Referer: {$this->referer}";
}
if ($this->cookies) {
$cookie = 'Cookie: ';
foreach ($this->cookies as $key => $value) {
$cookie .= "$key=$value; ";
}
$headers[] = $cookie;
}
if ($this->username && $this->password) {
$headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password);
}
if ($this->postdata) {
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Content-Length: '.strlen($this->postdata);
}
$request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata;
return $request;
}
function getStatus() {
return $this->status;
}
function getContent() {
return $this->content;
}
function getHeaders() {
return $this->headers;
}
function getHeader($header) {
$header = strtolower($header);
if (isset($this->headers[$header])) {
return $this->headers[$header];
} else {
return false;
}
}
function getError() {
return $this->errormsg;
}
function getCookies() {
return $this->cookies;
}
function getRequestURL() {
$url = 'https://'.$this->host;
if ($this->port != 80) {
$url .= ':'.$this->port;
}
$url .= $this->path;
return $url;
}
function setUserAgent($string) {
$this->user_agent = $string;
}
function setAuthorization($username, $password) {
$this->username = $username;
$this->password = $password;
}
function setCookies($array) {
$this->cookies = $array;
}
function useGzip($boolean) {
$this->use_gzip = $boolean;
}
function setPersistCookies($boolean) {
$this->persist_cookies = $boolean;
}
function setPersistReferers($boolean) {
$this->persist_referers = $boolean;
}
function setHandleRedirects($boolean) {
$this->handle_redirects = $boolean;
}
function setMaxRedirects($num) {
$this->max_redirects = $num;
}
function setHeadersOnly($boolean) {
$this->headers_only = $boolean;
}
function setDebug($boolean) {
$this->debug = $boolean;
}
function quickGet($url) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
if (isset($bits['query'])) {
$path .= '?'.$bits['query'];
}
$client = new HttpClient($host, $port);
if (!$client->get($path)) {
return false;
} else {
return $client->getContent();
}
}
function quickPost($url, $data) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
$client = new HttpClient($host, $port);
if (!$client->post($path, $data)) {
return false;
} else {
return $client->getContent();
}
}
function debug($msg, $object = false) {
if ($this->debug) {
print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg;
if ($object) {
ob_start();
print_r($object);
$content = htmlentities(ob_get_contents());
ob_end_clean();
print '<pre>'.$content.'</pre>';
}
print '</div>';
}
}
}
?>
```
2、建立一個接口使用類,
```
<?php
namespace feieyun;
use feieyun\HttpClient;
class Feieyun {
protected $USER='2547895205@qq.com';//*必填*:飛鵝云后臺注冊賬號
protected $UKEY='m4XcfzbLwRpZXL3Z';//*必填*: 飛鵝云后臺注冊賬號后生成的UKEY 【備注:這不是填打印機的KEY】
protected $SN; //*必填*:打印機編號,必須要在管理后臺里添加打印機或調用API接口添加之后,才能調用API
//以下參數不需要修改
protected $IP='api.feieyun.cn';//接口IP或域名
protected $PORT=80;//接口IP端口
protected $PATH='/Api/Open/';//接口IP或域名
public function __construct($SN="",$USER = '',$UKEY='')
{
if(!empty($SN)){
$this->SN = $SN;
}
if(!empty($USER)){
$this->USER = $USER;
}
if(!empty($USER)){
$this->UKEY = $UKEY;
}
}
public function batchDel($snlistData){
$snlist="";
$snlistDataCount=count($snlistData);
$i=0;
foreach ($snlistData as $key => $value) {
$i++;
if($i>=$snlistDataCount){
$snlist .= "{$value}";
}else{
$snlist .= "{$value}-";
}
}
// var_dump($printerContent);die;
$this->printerDelList($snlist);
}
//添加打印機
/*
使用案例
$printerConten => 打印機編號sn(必填) # 打印機識別碼key(必填) # 備注名稱(選填) # 流量卡號碼(選填),多臺打印機請換行(\n)添加新打印機信息,每次最多100臺。
$printerData=[
["Sn"=>"921555411","KEY"=>"amnkatm5","remark"=>"測試","carnum"=>""],
// ["Sn"=>"921555412","KEY"=>"amnkatm2","remark"=>"測試2","carnum"=>""],
];
$Feieyun=new Feieyun();
$Feieyun->batchAdd($printerData);
*/
public function batchAdd($printerData){
$printerContent="";
$printerDataCount=count($printerData);
$i=0;
foreach ($printerData as $key => $value) {
$i++;
$SN=$value["Sn"];
$KEY=$value["KEY"];
$remark=$value["remark"];
$carnum=$value["carnum"];
if($i>=$printerDataCount){
$printerContent .= "{$SN}#{$KEY}#{$remark}#{$carnum}";
}else{
$printerContent .= "{$SN}#{$KEY}#{$remark}#{$carnum}\n";
}
}
// var_dump($printerContent);die;
$this->printerAddlist($printerContent);
}
// $title,$goods,$note,$extension
public function printReceipts($title,$goods,$note,$extension){
/*
使用案例
$Feieyun=new Feieyun("921555411");
$title="測試標題api".time();
$note="測試備注api".time();
$goods=[
["name"=>"測試商品","price"=>"10.00","num"=>3],
["name"=>"測試商品品","price"=>"10.00","num"=>3],
["name"=>"測試商品3測試商品2測試商品2","price"=>"10.00","num"=>3],
];
$extension =[
["name"=>"測試","value"=>"10.00" ],
["name"=>"測試商品1","value"=>"10.00" ],
["name"=>"時間","value"=>date("Y-m-d") ],
];
$Feieyun->printReceipts($title,$goods,$note,$extension);
*/
$content = '<CB>'.$title.'</CB><BR>';
$content .= '名稱 單價 數量 金額<BR>';
$content .= '--------------------------------<BR>';
$total_price=0;
foreach ($goods as $key => $value) {
$numprice=$value['price']*$value['num'];
$total_price=$total_price+$numprice;
if(mb_strlen($value['name'])>=8){
$name=mb_substr( $value['name'],0,6,"utf-8" ) ;
$content .= $name."... {$value['price']} {$value['num']} {$numprice}<BR>";
}else{
$emptynum=8-mb_strlen($value['name']);
$content .= $value['name'].str_repeat(' ',$emptynum)." {$value['price']} {$value['num']} {$numprice}<BR>";
}
}
$content .= "備注:{$note}<BR>";
$content .= '--------------------------------<BR>';
$content .= "合計:{$total_price}元<BR>";
foreach ($extension as $key => $value) {
$content .= "{$value['name']}:{$value['value']}<BR>";
}
// $content .= '<QR>http://www.feieyun.com</QR>';//把二維碼字符串用標簽套上即可自動生成二維碼
//提示:
//SN => 打印機編號
//$content => 打印內容,不能超過5000字節
//$times => 打印次數,默認為1。
//打開注釋可測試
$this->printMsg($this->SN,$content,1);//該接口只能是小票機使用,如購買的是標簽機請使用下面方法3,調用打印
}
/**
* [批量添加打印機接口 Open_printerAddlist]
* @param [string] $printerContent [打印機的sn#key]
* @return [string] [接口返回值]
*/
public function printerAddlist($printerContent){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_printerAddlist',
'printerContent'=>$printerContent
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
$result = $client->getContent();
return json_encode($result);
}
}
/**
* 打印訂單[接口 Open_printMsg]
* @param [string] $sn [打印機編號sn]
* @param [string] $content [打印內容]
* @param [string] $times [打印聯數]
* @return [string] [接口返回值]
*/
public function printMsg($sn,$content,$times){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_printMsg',
'sn'=>$sn,
'content'=>$content,
'times'=>$times//打印次數
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
//服務器返回的JSON字符串,建議要當做日志記錄起來
$result = $client->getContent();
return json_encode($result);
}
}
/**
* 標簽機打印訂單[接口 Open_printLabelMsg]
* @param [string] $sn [打印機編號sn]
* @param [string] $content [打印內容]
* @param [string] $times [打印聯數]
* @return [string] [接口返回值]
*/
public function printLabelMsg($sn,$content,$times){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_printLabelMsg',
'sn'=>$sn,
'content'=>$content,
'times'=>$times//打印次數
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
//服務器返回的JSON字符串,建議要當做日志記錄起來
$result = $client->getContent();
return json_encode($result);
}
}
/**
* 批量刪除[打印機 Open_printerDelList]
* @param [string] $snlist [打印機編號,多臺打印機請用減號“-”連接起來]
* @return [string] [接口返回值]
*/
public function printerDelList($snlist){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_printerDelList',
'snlist'=>$snlist
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
$result = $client->getContent();
return json_encode($result);
}
}
/**
* 修改打印機信息[接口 Open_printerEdit]
* @param [string] $sn [打印機編號]
* @param [string] $name [打印機備注名稱]
* @param [string] $phonenum [打印機流量卡號碼,可以不傳參,但是不能為空字符串]
* @return [string] [接口返回值]
*/
public function printerEdit($sn,$name,$phonenum){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_printerEdit',
'sn'=>$sn,
'name'=>$name,
'phonenum'=>$phonenum
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
$result = $client->getContent();
return json_encode($result);
}
}
/**
* 清空待打印訂單[接口 Open_delPrinterSqs]
* @param [string] $sn [打印機編號]
* @return [string] [接口返回值]
*/
public function delPrinterSqs($sn){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_delPrinterSqs',
'sn'=>$sn
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
$result = $client->getContent();
return json_encode($result);
}
}
/**
* 查詢訂單是否打印成功[接口 Open_queryOrderState]
* @param [string] $orderid [調用打印機接口成功后,服務器返回的JSON中的編號 例如:123456789_20190919163739_95385649]
* @return [string] [接口返回值]
*/
public function queryOrderState($orderid){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_queryOrderState',
'orderid'=>$orderid
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
$result = $client->getContent();
return json_encode($result);
}
}
/**
* [查詢指定打印機某天的訂單統計數接口 Open_queryOrderInfoByDate]
* @param [string] $sn [打印機的編號]
* @param [string] $date [查詢日期,格式YY-MM-DD,如:2019-09-20]
* @return [string] [接口返回值]
*/
public function queryOrderInfoByDate($sn,$date){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_queryOrderInfoByDate',
'sn'=>$sn,
'date'=>$date
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
$result = $client->getContent();
return json_encode($result);
}
}
/**
* 獲取某臺打印機狀態[接口 Open_queryPrinterStatus]
* @param [string] $sn [打印機編號]
* @return [string] [接口返回值]
*/
public function queryPrinterStatus($sn){
$time = time(); //請求時間
$msgInfo = array(
'user'=>$this->USER,
'stime'=>$time,
'sig'=>$this->signature($time),
'apiname'=>'Open_queryPrinterStatus',
'sn'=>$sn
);
$client = new HttpClient($this->IP,$this->PORT);
if(!$client->post($this->PATH,$msgInfo)){
return 'error';
}else{
$result = $client->getContent();
return json_encode($result);
}
}
/**
* [signature 生成簽名]
* @param [string] $time [當前UNIX時間戳,10位,精確到秒]
* @return [string] [接口返回值]
*/
public function signature($time){
return sha1($this->USER.$this->UKEY.$time);//公共參數,請求公鑰
}
}
//****************************************方法3 標簽機專用打印訂單接口****************************************************
//***接口返回值說明***
//正確例子:{"msg":"ok","ret":0,"data":"123456789_20160823165104_1853029628","serverExecutedTime":6}
//錯誤例子:{"msg":"錯誤信息.","ret":非零錯誤碼,"data":null,"serverExecutedTime":5}
//標簽說明:
// $content = "<DIRECTION>1</DIRECTION>";//設定打印時出紙和打印字體的方向,n 0 或 1,每次設備重啟后都會初始化為 0 值設置,1:正向出紙,0:反向出紙,
// $content .= "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001 五號桌 1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可樂雞翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>張三先生 13800138000</TEXT>";//40mm寬度標簽紙打印例子,打開注釋調用標簽打印接口打印
//提示:
//SN => 打印機編號
//$content => 打印內容,不能超過5000字節
//$times => 打印次數,默認為1。
//打開注釋可測試
// printLabelMsg(SN,$content,1);//打開注釋調用標簽機打印接口進行打印,該接口只能是標簽機使用,其它型號打印機請勿使用該接口
//************************************方法5 修改打印機信息接口************************************************
//***接口返回值說明***
//成功:{"msg":"ok","ret":0,"data":true,"serverExecutedTime":5}
//錯誤:{"msg":"參數錯誤 : 參數值不能傳空字符,\"\"、\"null\"、\"undefined\".","ret":-2,"data":null,"serverExecutedTime":1}
//提示:
//SN => 打印機編號
//$name => 打印機備注名稱
//$phonenum => 打印機流量卡號碼
//打開注釋可測試
//$name = "飛鵝云打印機";
//$phonenum = "01234567891011121314";
// printerEdit(SN,$name,$phonenum);
//************************************方法6 清空待打印訂單接口************************************************
//***接口返回值說明***
//成功:{"msg":"ok","ret":0,"data":true,"serverExecutedTime":4}
//錯誤:{"msg":"驗證失敗 : 打印機編號和用戶不匹配.","ret":1002,"data":null,"serverExecutedTime":3}
//錯誤:{"msg":"參數錯誤 : 參數值不能傳空字符,\"\"、\"null\"、\"undefined\".","ret":-2,"data":null,"serverExecutedTime":2}
//提示:
//SN => 打印機編號
//打開注釋可測試
// delPrinterSqs(SN);
//*********************************方法7 查詢訂單是否打印成功接口*********************************************
//***接口返回值說明***
//正確例子:
//已打印:{"msg":"ok","ret":0,"data":true,"serverExecutedTime":6}
//未打印:{"msg":"ok","ret":0,"data":false,"serverExecutedTime":6}
//提示:
//$orderid => 訂單ID,由方法1接口Open_printMsg返回。
//打開注釋可測試
//$orderid = "123456789_20160823165104_1853029628";//訂單ID,從方法1返回值中獲取
//queryOrderState($orderid);
//*****************************方法8 查詢指定打印機某天的訂單統計數接口*****************************************
//***接口返回值說明***
//正確例子:
//{"msg":"ok","ret":0,"data":{"print":6,"waiting":1},"serverExecutedTime":9}
//錯誤:{"msg":"驗證失敗 : 打印機編號和用戶不匹配.","ret":1002,"data":null,"serverExecutedTime":3}
//提示:
//$date => 查詢日期,格式YY-MM-DD,如:2016-09-20
//打開注釋可測試
// $date = "2016-09-20";
// queryOrderInfoByDate(SN,$date);
//***********************************方法9 獲取某臺打印機狀態接口***********************************************
//***接口返回值說明***
//正確例子:
//{"msg":"ok","ret":0,"data":"離線","serverExecutedTime":9}
//{"msg":"ok","ret":0,"data":"在線,工作狀態正常","serverExecutedTime":9}
//{"msg":"ok","ret":0,"data":"在線,工作狀態不正常","serverExecutedTime":9}
//提示:
//SN => 填打印機編號
//打開注釋可測試
// queryPrinterStatus(SN);
?>
```
3、使用
```
use feieyun\Feieyun;
/*打印*/
public function index()
{
$Feieyun=new Feieyun("921555411");
$title="測試標題api".time();
$note="測試備注api".time();
$goods=[
["name"=>"測試商品","price"=>"10.00","num"=>3],
["name"=>"測試商品品","price"=>"10.00","num"=>3],
["name"=>"測試商品3測試商品2測試商品2","price"=>"10.00","num"=>3],
];
$extension =[
["name"=>"測試","value"=>"10.00" ],
["name"=>"測試商品1","value"=>"10.00" ],
["name"=>"時間","value"=>date("Y-m-d") ],
];
$Feieyun->printReceipts($title,$goods,$note,$extension);
}
//*************************************批量添加打印機接口*************************************************
//提示:
//$printerConten => 打印機編號sn(必填) # 打印機識別碼key(必填) # 備注名稱(選填) # 流量卡號碼(選填), 每次最多100臺。
public function add()
{
$printerData=[
["Sn"=>"921555411","KEY"=>"amnkatm5","remark"=>"測試","carnum"=>""],
// ["Sn"=>"921555412","KEY"=>"amnkatm2","remark"=>"測試2","carnum"=>""],
];
$Feieyun=new Feieyun();
$Feieyun->batchAdd($printerData);
}
//************************************* 批量刪除打印機接口*************************************************
//提示:
//$printerConten => 打印機編號sn(必填) , 每次最多100臺 。
public function del()
{
$printerData=[
921555411,
];
$Feieyun=new Feieyun();
$Feieyun->batchDel($printerData);
}
```
- 服務器購買到搭建寶塔
- 結構規范
- php基礎
- php簡介
- php是什么
- PHP 能做什么
- PHP 如何運行
- 如何了解弱語言
- 安裝環境
- 安裝LNMP
- 寶塔
- phpstudy
- PHP基本語法
- PHP 標記
- 從 HTML 中分離
- 指令分隔符
- 注釋
- php 數據類型
- 類型檢測
- 四種標量類型
- boolean(布爾型)
- Integer 整型
- Float 浮點型
- String 字符串類型
- 兩種復合類型
- array(數組)
- object(對象)
- 兩種特殊類型
- resource(資源)
- NULL(無類型)
- 類型轉換
- 變量
- 變量定義和命名規范
- 傳值和引用
- 預定義變量
- php預定義變量
- $_SERVER詳解
- 變量范圍
- 全局變量
- 靜態變量
- 可變變量
- 常量
- 常量簡介
- 常量定義
- 相比變量
- 魔術常量
- 運算符
- 運算符簡介
- 算術運算符
- 賦值運算符
- 位運算符
- 比較運算符
- 錯誤控制運算符
- 執行運算符
- 遞增(減)運算符
- 邏輯運算符
- 字符串運算符
- 數組運算符
- 新增操作符
- 控制結構
- 控制簡介
- if 語句
- while 語句
- for 語句
- foreach 語句
- break 語句
- continue 語句
- switch 語句
- declare 語句
- return 語句
- include 語句
- PHP 函數
- 函數簡介
- 用戶自定義函數
- 函數的參數
- 返回值
- 可變函數
- 內部函數
- 匿名函數
- PHP 的類和對象
- PHP 的類和對象簡介
- 基本概念
- 對象繼承
- 屬性
- 類常量
- 自動加載對象
- 構造和析構函數
- 訪問控制
- 范圍解析操作符(::)
- 靜態static
- Static 關鍵字
- 抽象類
- 接口
- 匿名類
- 面向對象其他特性
- const關鍵字
- final關鍵字
- abstract用于定義抽象方法和抽象類。
- self、$this、parent::關鍵字
- 接口(interface)
- trait關鍵字
- instanceof關鍵字
- 魔術方法
- 構造函數和析構函數
- 私有屬性的設置獲取
- __toString()方法
- __clone()方法
- __call()方法
- 類的自動加載
- 會話控制
- cookie
- PHP 操作 cookie
- 項目實戰
- SESSION
- Session 的初步介紹與實驗準備
- PHP 操作 session
- 項目實戰2
- http
- 特點
- 工作過程
- request
- response
- HTTP狀態碼
- URL
- GET和POST的區別
- HTTPS
- 常用函數
- 常用的字符串函數
- 常用的數組函數
- 常用文件函數
- 常用時間函數
- 常用日歷函數
- 常用url函數
- 面試題常見
- 時間戳
- 技術類文檔
- 技術開發文檔
- 開發環境
- 開發規范
- 注釋規范
- 開發目錄結構
- 數據庫字典
- 路由
- 定時任務
- 獲取系統配置
- 系統常用函數
- 后臺表單
- 消息隊列
- 第三方類庫標注
- 需求文檔
- 數據庫
- MYSQL
- 事務(重點)
- 索引
- 存儲過程
- 觸發器
- 視圖
- 導入導出數據庫
- 優化mysql數據庫的方法
- MyISAM與InnoDB區別
- 外連接、內連接的區別
- 物理文件結構
- MongoDB
- Redis
- 運用場景和實例
- pgsql
- 服務器
- Nginx
- 正向代理和反向代理
- 負載均衡
- Linux常用命令
- 基本目錄和命令
- php開發工具
- phpStorm編輯器
- 安裝和漢化
- 鏈接ftp
- 常用操作
- 常用快捷鍵
- 自定義快捷鍵
- 使用快捷鍵新建目錄和文件
- 使用快捷鍵快速查找文件、類、方法
- 多文件切換
- 快速搜索設置項
- 多點編輯
- 方法重構
- 自定義文件模板和代碼片段
- 自定義文件模板
- 自定義代碼片段
- Xdebug 調試插件
- 安裝Xdebug 調試插件
- 在PHPStorm 中使用 Xdebug 插件調試代碼
- Vi Box虛擬機
- Vi Box 虛擬機 Oracle VM VirtualBox
- 虛擬機輔助工具一-Vagrant
- 華碩主板BIOS設置中VT虛擬化技術選項怎么開啟 Oracle VM VirtualBox
- 溝通工具
- 文檔分享
- 流程圖
- 任務分配
- 代碼托管
- 缺陷管理
- 設計圖
- gitLab
- 安裝
- 漢化
- Gitlab 用戶和項目管理
- Gitlab 持續集成與自動構建實踐
- PHP進階
- 大流量解決方案
- PSR規范
- RESTFUL規范
- 設計模式
- 單例模式
- 策略模式
- 工廠模式
- 簡單工廠模式
- 工廠方法模式
- 抽象工廠模式
- 外觀模式
- 享元模式
- 代理模式
- 命令模式
- 中介者模式
- 觀察者模式
- 狀態模式
- 建筑者模式
- 適配器模式
- 橋接模式
- 裝飾器模式
- 排序算法
- 冒泡排序算法
- 二分查找算法
- 直接插入排序算法
- 希爾排序算法
- 選擇排序算法
- 快速排序算法
- 常見網絡攻擊類型
- CSRF攻擊
- XSS攻擊
- SQL注入
- Cookie攻擊
- thinkphp
- thinkphp5命令行
- git
- Git 常用命令操作和基礎學習
- 傻瓜與白癡的筆記本
- 學習
- 一、Git 與 GitHub 的來歷
- 二、在 GitHub 上創建倉庫
- 三、安裝
- Windows 上安裝 Git
- 安裝2
- 四、克隆 GitHub 上的倉庫到本地
- 五、GIT基本操作哦
- 六、Git 分支操作
- 一、添加SSH關聯授權
- 二、為 Git 命令設置別名
- 三、Git 分支管理
- 七、多人協作 GitHub 部分
- 八、多人協作 Git 部分
- 九、Git tag 和 GitHub releases
- composer
- Composer 基礎使用
- 安裝和使用
- 在項目中集成PHPmailer
- 認識composer.json和composer.lock文件
- composer的其他命令操作
- 本地創建composer包
- 提交自己的依賴包到composer Packagist
- crontab計劃任務
- Linux任務計劃crontab
- php 的 計劃任務——Crontab
- bootstrap前端框架
- 入門
- 實戰技巧
- 后臺模板樣式——admin
- 第三方接口對接
- 微信
- 敏感詞過濾
- 微信圖片檢測
- 短信類型
- 阿里云短信
- 容聯云短信
- 飛鴿短信
- 媒體
- 新聞接口測試
- 免費新聞
- 免費視頻
- nba賽事,未測試
- 豆瓣電影接口
- 音樂接口
- 網易短視頻接口
- 知乎微信接口
- 百度ai
- 百度語音
- 圖片識別
- 騰訊
- 騰訊im
- 騰訊云直播
- 騰訊滑動驗證
- 物流快遞
- 快遞鳥、快遞100
- 推送
- 極光推送
- 地圖&天氣
- 獲取城市和天氣預報
- 地址獲取和定位
- 地址轉換經緯度
- 圖片類型
- 360新聞圖片
- 多平臺翻譯
- 實名認證
- 七牛云
- 云合同
- 多站點收錄查詢接口
- 打印機
- 第三方登錄
- 微信登錄
- 支付
- 支付寶app支付
- 微信提現+退款
- 微信app支付
- 微信支付公式
- 類庫
- 圖片類
- phpqrcode實戰:生成二維碼
- 圖片處理類
- 驗證碼類
- 消息類
- PHPMailer
- 分詞類
- ik
- PHPAnalysis
- 自己封裝的方法
- GD庫
- 自動獲取圖片主題顏色
- 圖片轉素描
- 生成海報
- 圖片轉字符
- 驗證碼
- 圖片轉黑白灰
- GD庫實現圖片水印與縮略圖
- Imagick擴展
- 將一張image圖片轉化為字符串的形式
- 基本方法
- 圖片路徑轉base64
- 生成文件后綴圖片
- url路徑判斷拼接
- 防篡改入口文件
- php中文姓名判斷
- 可控抽獎
- 特殊截取
- 銀行卡位(特殊卡號不支持)
- 微信紅包計算
- 數組和對象互轉
- php批量更新修改數據庫
- base64_img上傳
- 刪庫刪目錄————跑路
- 字符串特殊符號過濾
- 首字母轉成默認頭像
- 生成隨機字符串
- 根據id轉 邀請碼
- 日志寫入
- 字符串截取,超出顯示省略號
- 清除html標簽+清除html標簽,字符串截取
- 計算時間差的函數和演示
- php判斷路徑是否是絕對路徑,如果不是拼接至絕對路徑
- sql 參數過濾
- php敏感詞過濾
- 省市區分別截取
- 生成csv
- 無限極分類
- api接口返回封裝的方法函數
- xml和數組互轉
- 獲取thinkph5下控制器和方法名
- 過濾
- 獲取服務器信息
- php隨機顏色
- 創建多級目錄
- 推廣碼
- 跨域檢測
- 二維碼
- 文檔類
- word
- PHPWord
- tcPdf
- MPDF
- dompdf
- FPDF、Fpdi類庫
- excel
- PhpSpreadsheet導入
- phpExcel
- 時間
- PHP-農歷+節氣+節日等類庫
- 時間類庫
- 最好用的是人性化時間差
- 文件管理類
- 文件操作類
- 文件夾操作
- php操作ftp的類庫
- curl
- 數據庫操作類
- Db擴展函數
- 數據庫備份
- 仿tp5的Db庫
- 不常用mysql
- 自動生成數據庫字典
- 字符串
- 字符串操作helper/Str
- 隨機生成姓名
- 隨機生成類
- php字符串類
- 中文轉拼音的類庫
- 分類
- 緩存
- 數據驗證
- 身份證相關操作
- 安全類
- 表單生成類
- 自動生成表單,未完待續中