PHP code example of hangjia / xcx
1. Go to this page and download the library: Download hangjia/xcx 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/ */
hangjia / xcx example snippets
$user = \HangJia\Xcx\Factory::user();
$re = $user->login();
// 输出
Array {
'code' => 200,
'msg' => '',
'data' => Array {
'user_name' => 'xxx', // 用户名
'partner_id' => 1, // 合作商ID
'app_id' => 13 // 应用ID
}
}
// $note(可选) 备注
$auth = \HangJia\Xcx\Factory::auth();
$url = $auth->getAuthUrl($app_id, $partner_id, $note = null);
// 获取地址后重定向到该地址
// $ext_json array 第三方小程序配置文件 详情见上方文档
$submit = \HangJia\Xcx\Factory::submit();
$re = $submit->release($app_id, $ext_json);
// 只返回队列号,异步接口,所以查看状态请使用 "发布状态" 接口。
$submit = \HangJia\Xcx\Factory::submit();
$re = $submit->status($app_id);
// 输出
Array {
code => 200,
'msg' => '',
'data' => Array {
'status' => 1,
'version' => '小程序版本号',
'desc' => '小程序版本备注',
'reason' => '错误描述', // status 为3,5时候出现
'platform' => Array { // 本数组显示线上的版本号,上面的数组显示的是你当前提交的版本信息
'version' => '版本号',
'desc' => '版本描述'
}
}
}
// secret_key(密钥)和partner_id(合作商ID)可在合作商后台-基本信息中找到
$platform = \HangJia\Xcx\Factory::platform([
'secret_key' => 'xxxxxxxxxxxxx'
]);
$ret = $platform->getToken($partner_id);
// 输出
Array {
"code": 200,
"msg": "success",
"data": Array {
"component_access_token": "1iovFkaJK.....................",
"expires_date": "2018-10-15 15:49:48" // 过期时间
}
}