PHP code example of brayun / yii2-wechat

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

    

brayun / yii2-wechat example snippets



'components' => [
	'wechat' => [
		'class' => 'brayun\wechat\Wechat',
		// 'wechatOptions' => []  # 不配置默认获取Yii::$app->params['WECHAT'],如配置则使用此配置
		// 'sessionParam' => '' # wechat user info will be stored in session under this key
		// 'returnUrlParam' => '' # returnUrl param stored in session
	],
]

// 微信网页授权:
if(Yii::$app->wechat->isWechat && !Yii::$app->wechat->isAuthorized()) {
	return Yii::$app->wechat->authorizeRequired();
}