PHP code example of superzc / qqminiprogram
1. Go to this page and download the library: Download superzc/qqminiprogram 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/ */
superzc / qqminiprogram example snippets
return [
'qq' => [
'appid' => 'xxx',
'appsecret' => 'xxx',
],
];
use Superzc\QQMiniprogram\QQMiniprogram;
use Superzc\QQMiniprogram\Exceptions\DefaultException as QQMPDefaultException;
try {
$qqminiprogram = new QQMiniprogram();
// 如果需要登录调用凭据,先获取access_token(有效期2小时,建议缓存,避免重复刷新),再设置access_token
$access_token = $qqminiprogram->getAccessToken();
$qqminiprogram->setAccessToken($access_token);
$result = $qqminiprogram->doSomething();
} catch (QQMPDefaultException $e) {
return response()->json([
'ret' => $e->getCode(),
'msg' => $e->getMessage(),
]);
}
use Superzc\QQMiniprogram\Facades\QQMiniprogram;
try {
// 如果需要登录调用凭据,先获取access_token(有效期2小时,建议缓存,避免重复刷新),再设置access_token
$access_token = QQMiniprogram::getAccessToken();
QQMiniprogram::setAccessToken($access_token);
$result = QQMiniprogram::doSomething();
} catch (QQMPDefaultException $e) {
return response()->json([
'ret' => $e->getCode(),
'msg' => $e->getMessage(),
]);
}