| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * @link:http://www.gdqijianshi.com/
- * @copyright: Copyright (c) 2020 广东七件事集团
- * Created by PhpStorm
- * Author: zal
- * Date: 2020-04-01
- * Time: 21:49
- */
- namespace common\helpers\printer\config;
- use common\helpers\printer\sdk\FeieYun;
- class FeieConfig extends BaseConfig
- {
- public $sn; // 打印机编号
- public $key; // 打印机密钥
- public $time; // 打印联数
- public $user; // 飞鹅云后台注册用户名
- public $ukey; // 飞鹅云后台登录生成的UKEY
- private $ip = 'api.feieyun.cn';
- private $path = '/Api/Open/';
- public function print($content)
- {
- date_default_timezone_set("Asia/Shanghai");
- $time = time();
- $content = array(
- 'user' => $this->user,
- 'stime' => $time,
- 'sig' => sha1($this->user . $this->ukey . $time),
- 'apiname' => 'Open_printMsg',
- 'sn' => $this->sn,
- 'content' => $content,
- 'times' => $this->time
- );
- $client = new FeieYun($this->ip, 80);
- if (!$client->post($this->path, $content)) {
- throw new \Exception($client->getError(), $client->getError(), 1);
- }
- $result = $client->getContent();
- $result = json_decode($result, true);
- if ($result['ret'] != 0) {
- throw new \Exception($result['msg'], $result, 1);
- }
- return $result;
- }
- }
|