入門
EasySwoole WeChat
組件公眾號的各模塊相對比較統(tǒng)一,用法如下:
在服務(wù)端中,我們通過如下方式獲取到公眾號操作相關(guān)的整個實(shí)例,用法如下:
<?php
$config = [
// 微信公眾平臺后臺的 appid
'appId' => 'wxefe41fdeexxxxxx',
// 微信公眾平臺后臺配置的 Token
'token' => 'dczmnau31ea9nzcnxxxxxxxxx',
// 微信公眾平臺后臺配置的 EncodingAESKey
'aesKey' => 'easyswoole',
// 微信公眾平臺后臺配置的 AppSecret
'appSecret' => 'your-AppSecret'
];
// 公眾號
$officialAccount = \EasySwoole\WeChat\Factory::officialAccount($config);
$officialAccount
在后文所有相關(guān)公眾號的文檔都是指 \EasySwoole\WeChat\Factory::officialAccount
得到的實(shí)例,下面就不在每個頁面單獨(dú)寫了。
重點(diǎn)總結(jié)
所有的應(yīng)用服務(wù)都通過主入口 EasySwoole\WeChat\Factory
類來創(chuàng)建:
<?php
use EasySwoole\WeChat\Factory;
// 公眾號
$officialAccount = Factory::officialAccount($config);
// 小程序
$miniProgram = Factory::miniProgram($config);
// 開放平臺
$openPlatform = Factory::openPlatform($config);
// 企業(yè)微信
$work = Factory::work($config);