PHP code example of ledc / yilianyun
1. Go to this page and download the library: Download ledc/yilianyun 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/ */
ledc / yilianyun example snippets
use Ledc\YiLianYun\YiLianYun;
// 文本打印
$result = YiLianYun::getInstance()->print('测试打印', time());
// 图片打印
$result = YiLianYun::getInstance()->picturePrint('https://www.baidu.com/img/bd_logo1.png', time());
// 直接调用POST方法,底层自动处理签名逻辑、AccessToken。
$result = YiLianYun::getInstance()->post('易联云接口地址', '易联云接口数组参数', true, true);
use Ledc\YiLianYun\Config;
use Ledc\YiLianYun\YiLianYun;
use support\Cache;
use support\Log;
$config = new Config([
'client_id' => '易联云开放平台:应用ID',
'client_secret' => '易联云开放平台:应用密钥',
'machine_code_prod' => '【生产】易联云打印机:终端号(非必填)',
'machine_code_test' => '【测试】易联云打印机:终端号(非必填)',
'develop_id' => '易联云开放平台:开发者ID(非必填)',
'timeout' => 10,
'enabled' => true,
'debug' => true,
]);
// 创建易联云SDK对象实例
$client = new YiLianYun($config, Cache::store(), Log::channel());
// 在创建SDK对象实例后,所有的方法都可以由IDE自动补全;例如:
// 文本打印
$result = $client->print('测试打印', time());
var_dump($result);
// 图片打印
$result = $client->picturePrint('https://www.baidu.com/img/bd_logo1.png', time());
var_dump($result);
// 直接调用POST方法,底层自动处理签名逻辑、AccessToken。
$result = $client->post('易联云接口地址', '易联云接口数组参数', true, true)
var_dump($result);