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