PHP code example of huijiewei / yii2-wechat

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

    

huijiewei / yii2-wechat example snippets



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

if(Wechat::getIsWechatClient()) {
    $wechatAuthorize = new WechatAuthorize([
        'wechat' => 'wechat', // componentId, 默认是 wechat
    ]);
    
    if(!$wechatAuthorize->isAuthorized()) {
        return $wechatAuthorize->authorizeRequired()->send();
    }
}

WechatShareWidget::widget([
    'wechat' => 'wechat', // componentId, 默认是 wechat
    'shareUrl' => '分享链接',
    'shareIcon' => '分享图标',
    'shareTitle' => '分享标题',
    'shareDescription' => '分享描述',
]);
bash
php yii migrate --migrationPath=@vendor/huijiewei/yii2-wechat/src/migrations