'qyWechat' => [
'class' => 'cdcchen\yii\wechat\QyClient',
'cache' => 'cache',
]
注:cache属性为必需项。
/* @var \cdcchen\yii\wechat\QyClient $wechat */
$wechat = Yii::$app->get('qyWechat');
获取【主动消息接口的 Access Token】
/* @var \cdcchen\yii\wechat\Token $token */
$token = $wechat->getDefaultToken($corpId, $secret);
获取【获取应用提供商凭证 Access Token】
/* @var \cdcchen\yii\wechat\Token $token */
$token = $wechat->getProviderToken($corpId, $secret);
$token 的类型为 \cdcchen\yii\wechat\Token:
cdcchen\yii\wechat\Token Object
(
[cropId] => wx4affdfc26d62c294
[value] => w2M2f2Tj4_-sGHrAv_kdi1__f61exwPUCnvvoJFQ0MPczYttF-22gZuYhV5GHQou
[expire] => 7200
[createdAt] => 1462331430
)
以获取微信回调服务器IP列表为例:
use cdcchen\wechat\qy\ServerClient;
$client = new ServerClient($accessToken);
$data = $client->getCallbackIP();