PHP code example of cblink / puyingcloud-sdk

1. Go to this page and download the library: Download cblink/puyingcloud-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cblink / puyingcloud-sdk example snippets


use Yan\PuyingCloudSdk\Kernel\ContentFormatter;


    'debug' => true, // 必须有,不然 foundation 72 行会报 Notice 未定义索引 debug 错误
    'phone' => 'your-phone-number',
    'password' => 'your-password',

    'log' => [
        'file' => __DIR__.'/runtime.log',
        'level' => 'debug',
        'permission' => 0777,
    ],

    'cache' => new \Doctrine\Common\Cache\FilesystemCache(__DIR__.'/cache/'),
]);

class TestFormatter extends ContentFormatter implements \Yan\PuyingCloudSdk\Contracts\Formatter {
    public function format()
    {
        $title = $this->title($this->content['title']);

        $this->result = $title;
    }
}

$order = [
    'title' => '123',
    'desc' => '456',
];

try {
    echo json_encode($sdk->printer->createPrintTask($sn, '测试打印', new TestFormatter($order)));
    
    echo json_encode($sdk->printer->getPrinterlist());
} catch (\Exception $e) {
    echo $e->getMessage();
}