huijiewei/yii2-wechat

微信插件

安装: 226

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

2.0.11 2020-10-09 08:55 UTC

This package is auto-updated.

Last update: 2024-09-09 17:14:44 UTC


README

Yii2 微信插件

本插件优化了微信网页授权流程

基于 overtrue/wechat.

安装

composer require huijiewei/yii2-wechat

配置

component 配置添加到 config/main.php

'components' => [
	// ...
	// componentId 可以自定义多个微信公众号进行配置
	'wechat' => [
		'class' => 'huijiewei\wechat\Wechat',
		// 'appConfig' => [],  # 公众号配置
		// 'paymentConfig' => [],  # 支付配置
		// 'miniProgramConfig' => [],  # 小程序配置
		// 'openPlatformConfig' => [],  # 开放平台配置
		// 'workConfig' => [],  # 企业微信配置
	],
	// ...
]

配置文档

配置数据库

php yii migrate --migrationPath=@vendor/huijiewei/yii2-wechat/src/migrations

用法

微信网页授权
if(Wechat::getIsWechatClient()) {
    $wechatAuthorize = new WechatAuthorize([
        'wechat' => 'wechat', // componentId, 默认是 wechat
    ]);
    
    if(!$wechatAuthorize->isAuthorized()) {
        return $wechatAuthorize->authorizeRequired()->send();
    }
}
JSSDK
WechatShareWidget::widget([
    'wechat' => 'wechat', // componentId, 默认是 wechat
    'shareUrl' => '分享链接',
    'shareIcon' => '分享图标',
    'shareTitle' => '分享标题',
    'shareDescription' => '分享描述',
]);

更多文档

查阅 EasyWeChat 文档.

感谢 overtrue/wechat