飞鹅云 php -sdk

Posted qmister

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了飞鹅云 php -sdk相关的知识,希望对你有一定的参考价值。

class Feieyun
{
    /**
     * @var string
     */
    protected $host = \'http://api.feieyun.cn/Api/Open/\';

    /**
     * @var
     */
    protected $config=[
        \'username\'=>\'\',
        \'uKey\'=>\'\',
    ];

    /**
     * Feieyun constructor.
     * @param $config
     */
    public function __construct(array $config)
    {
        $this->config = array_merge($this->config,$config);
    }



    /**
     * 添加打印机
     * @return mixed
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function add(array $private_params = [])
    {
        // TODO: Implement add() method.
        return $this->request($private_params, \'Open_printerAddlist\');
    }

    /**
     * 更新打印机
     * @param array $private_params
     * @return mixed
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function update($private_params = [])
    {
        // TODO: Implement update() method.
        return $this->request($private_params, \'Open_printerEdit\');
    }

    /**
     * 删除打印机
     * @param array $private_params
     * @return mixed
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function delete($private_params = [])
    {
        // TODO: Implement delete() method.
        return $this->request($private_params, \'Open_printerDelList\');
    }

    /**
     * 清空待打印队列
     * @param array $private_params
     * @return mixed
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function clear($private_params = [])
    {
        // TODO: Implement clear() method.
        return $this->request($private_params, \'Open_delPrinterSqs\');
    }

    /**
     * 打印机状态
     * @param array $private_params
     * @return mixed
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function status($private_params = [])
    {
        // TODO: Implement status() method.
        return $this->request($private_params, \'Open_queryPrinterStatus\');
    }


    /**
     * @param array $private_params
     * @param string $type
     * @return string
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function outputOrder($private_params = [], $type = \'\')
    {
        if ($type == \'lable\')
            return $this->outputLabelMsg($private_params);
        return $this->outputMsg($private_params);
    }

    /**
     * 打印订单
     * @param array $private_params
     * @return string
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function outputMsg($private_params = [])
    {
        return $this->request($private_params, \'Open_printMsg\');
    }

    /**
     * 标签机打印订单
     * @param array $private_params
     * @return string
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function outputLabelMsg($private_params = [])
    {
        return $this->request($private_params, \'Open_printLabelMsg\');
    }

    /**
     * 查询订单是否打印成功
     * @param array $private_params
     * @return string
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function orderStatus($private_params = [])
    {
        return $this->request($private_params, \'Open_queryOrderState\');
    }

    /**
     * 查询指定打印机某天的订单统计数
     * @param array $private_params
     * @return string
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function orderCount($private_params = [])
    {
        return $this->request($private_params, \'Open_queryOrderState\');
    }

    /**
     * @param array $private_params
     * @param string $apiname
     * @return string
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    public function request(array $private_params, string $apiname)
    {
        $public_params = [
            \'user\' => $this->config[\'username\'],
            \'stime\' => $this->getTime(),
            \'sig\' => $this->getSig(),
            \'apiname\' => $apiname,
        ];
        $params = array_filter(array_merge($public_params, $private_params));
        return $this->post($this->config[\'host\'] ?? $this->host, $params);
    }

    /**
     * @param string $url
     * @param array $params
     * @param array $headers
     * @return string
     * @throws \\GuzzleHttp\\Exception\\GuzzleException
     */
    protected function post(string $url, array $params = [], array $headers = [])
    {
        $resp = (new \\GuzzleHttp\\Client())->request(\'post\', $url, [
            \'headers\' => $headers,
            \'form_params\' => $params,
        ]);;
        return $resp->getBody()->getContents();
    }

    /**
     * @return string
     */
    protected function getSig()
    {
        return sha1($this->config[\'username\'] . $this->config[\'uKey\'] . $this->getTime());
    }

    /**
     * @return int
     */
    protected function getTime()
    {
        return time();
    }
}

以上是关于飞鹅云 php -sdk的主要内容,如果未能解决你的问题,请参考以下文章

如何远程使用PHP云主机的MYSQL

PHP 基于词频的PHP标签云

iapp云后台php源码怎么配置

PHP--腾讯云服务器上部署LNMP环境

阿里云CentOS7搭建Apache+PHP+MySQL环境,注意php加载mysql的方法

自己在apache+php+sql server下搭建了个网站,要怎么上传到腾讯云呢?腾讯云如何使用,如何购买?