PHP code example of myshero / yii2-easy-wechat
1. Go to this page and download the library: Download myshero/yii2-easy-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/ */
myshero / yii2-easy-wechat example snippets
// here are some representative examples that will help you:
// 微信网页授权:
public function actionIndex()
{
$wechat = \Yii::$app->wechat;
if ($wechat->isGuest()) {
// 跳转微信服务器授权
return $wechat->prepareOauth();
}else{
// do something ...
}
}
/**
* 授权回调
*/
public function actionOauth()
{
$wechat = \Yii::$app->wechat;
return $wechat->oauth();
}
------
\Yii::$app->wechat->officialAccount; // 公众号
\Yii::$app->wechat->miniProgram; // 小程序
\Yii::$app->wechat->openPlatform; // 开放平台
\Yii::$app->wechat->payment; // 微信支付
\Yii::$app->wechat->work; // 企业微信