superzc / qqminiprogram
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
README
This package provides additional features to the Laravel framework.
Installation
You can install the package via composer:
composer require superzc/qqminiprogram
Usage
修改小程序配置文件config/miniprogram.php
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(), ]); }
Change log
暂无