Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huijiewei/yii2-wechat
Yii2 微信扩展
https://github.com/huijiewei/yii2-wechat
Last synced: about 1 month ago
JSON representation
Yii2 微信扩展
- Host: GitHub
- URL: https://github.com/huijiewei/yii2-wechat
- Owner: huijiewei
- Created: 2018-06-16T11:46:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T05:53:14.000Z (2 months ago)
- Last Synced: 2024-11-29T14:43:27.358Z (about 1 month ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yii2-wechat
Yii2 微信扩展本扩展优化了微信网页授权流程
基于 [w7corp/easywechat](https://github.com/w7corp/easywechat).
## 安装
```
composer require huijiewei/yii2-wechat
```## 配置
增加 `component` 配置到 `config/main.php`:
```php
'components' => [
// ...
// componentId 可以自定义多个微信公众号进行配置
'wechat' => [
'class' => 'huijiewei\wechat\Wechat',
// 'appConfig' => [], # 公众号配置
// 'paymentConfig' => [], # 支付配置
// 'miniProgramConfig' => [], # 小程序配置
// 'openPlatformConfig' => [], # 开放平台配置
// 'workConfig' => [], # 企业微信配置
],
// ...
]
```[配置文档](https://easywechat.com/6.x/official-account/config.html)
## 配置数据库
```bash
php yii migrate --migrationPath=@vendor/huijiewei/yii2-wechat/src/migrations
```## 用法
##### 微信网页授权:
```php
if(Wechat::getIsWechatClient()) {
$wechatAuthorize = new WechatAuthorize([
'wechat' => 'wechat', // componentId, 默认是 wechat
]);
if(!$wechatAuthorize->isAuthorized()) {
return $wechatAuthorize->authorizeRequired()->send();
}
}
```##### JSSDK
```php
WechatShareWidget::widget([
'wechat' => 'wechat', // componentId, 默认是 wechat
'shareUrl' => '分享链接',
'shareIcon' => '分享图标',
'shareTitle' => '分享标题',
'shareDescription' => '分享描述',
]);
```### 更多文档
查阅 [EasyWeChat 文档](https://www.easywechat.com/docs).感谢 `w7corp/easywechat`