PHP code example of cdcchen / yii2-wechat

1. Go to this page and download the library: Download cdcchen/yii2-wechat 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/ */

    

cdcchen / yii2-wechat example snippets


'qyWechat' => [
    'class' => 'cdcchen\yii\wechat\QyClient',
    'cache' => 'cache',
]

/* @var \cdcchen\yii\wechat\QyClient $wechat */
$wechat = Yii::$app->get('qyWechat');

/* @var \cdcchen\yii\wechat\Token $token */
$token = $wechat->getDefaultToken($corpId, $secret);

/* @var \cdcchen\yii\wechat\Token $token */
$token = $wechat->getProviderToken($corpId, $secret);

cdcchen\yii\wechat\Token Object
(
    [cropId] => wx4affdfc26d62c294
    [value] => w2M2f2Tj4_-sGHrAv_kdi1__f61exwPUCnvvoJFQ0MPczYttF-22gZuYhV5GHQou
    [expire] => 7200
    [createdAt] => 1462331430
)

use cdcchen\wechat\qy\ServerClient;
$client = new ServerClient($accessToken);
$data = $client->getCallbackIP();