brayun/yii2-wechat

wechat sdk for yii2, base easy wechat

1.3 2017-09-07 13:17 UTC

This package is not auto-updated.

Last update: 2024-11-09 02:41:27 UTC


README

composer require brayun/yii2-wechat

Configuration

Add the SDK as a yii2 application component in the config/main.php:

'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();
}