|
1 месяц назад | |
---|---|---|
.. | ||
Demo | 1 месяц назад | |
Lib | 1 месяц назад | |
.gitignore | 1 месяц назад | |
.travis.yml | 1 месяц назад | |
README.md | 1 месяц назад | |
composer.json | 1 месяц назад | |
phpunit.xml | 1 месяц назад |
PHP >= 5.4
composer require yly-openapi/yly-openapi-sdk:v1.0.1
若composer失败,请换到国内镜像
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
<?php
//composer下加载方式
include_once __DIR__ . "/vendor/autoload.php";
//gitHub下载加载方式
include_once __DIR__ . "/Lib/Autoloader.php";
//初始化配置
use App\Config\YlyConfig;
$config = new YlyConfig('你的应用id', '你的应用密钥');
//获取token
use App\Oauth\YlyOauthClient;
$client = new YlyOauthClient($config);
$token = $client->getToken(); //若是开放型应用请传授权码code
var_dump($token);
//授权打印机(自有型应用使用,开放型应用请跳过该步骤)
use App\Api\PrinterService;
$printer = new PrinterService($token->access_token, $config);
$data = $printer->addPrinter('你的机器码', '你的机器密钥', '机器昵称也可不填', 'gprs卡号没有可不填');
var_dump($data);
//调取文本打印
use App\Api\PrintService;
$print = new PrintService($token->access_token, $config);
$data = $print->index('你的机器码','打印内容排版可看Demo下的callback.php','你的系统内部id自定义32位以内');
var_dump($data);
//调取图形打印
use App\Api\PicturePrintService;
$print = new PicturePrintService($token->access_token, $config);
$data = $print->index('你的机器码','打印内容排版可看Demo下的callback.php','你的系统内部id自定义32位以内');
var_dump($data);