<?php
namespace app\common\library\printer\engine;
use app\common\library\printer\party\FeieHttpClient;
class Feie extends Basics
{
const IP = 'api.feieyun.cn';
const PORT = 80;
const PATH = '/Api/Open/';
public function printTicket($content)
{
$params = $this->getParams($content);
$client = new FeieHttpClient(self::IP, self::PORT);
if (!$client->post(self::PATH, $params)) {
$this->error = $client->getError();
return false;
}
$result = json_decode($client->getContent());
log_write($result);
if ($result->ret != 0) {
$this->error = $result->msg;
return false;
}
return true;
}
private function getParams(&$content)
{
$time = time();
return [
'user' => $this->config['USER'],
'stime' => $time,
'sig' => sha1("{$this->config['USER']}{$this->config['UKEY']}{$time}"),
'apiname' => 'Open_printMsg',
'sn' => $this->config['SN'],
'content' => $content,
'times' => $this->times ];
}
}