第一步:先創(chuàng)建微信開(kāi)放平臺(tái):微信開(kāi)放平臺(tái),綁定微信小程序和公眾號(hào)(是為后面拿共用的unionid進(jìn)行小程序openid與公眾號(hào)openid綁定)
第二步:進(jìn)入公眾號(hào)開(kāi)放平臺(tái),找到基本配置,配置服務(wù)器地址(url):指自己服務(wù)器能夠訪(fǎng)問(wèn)的域名
第三步:在服務(wù)器中就是url寫(xiě)下這個(gè)方法
/* *接收微信信息 */
public function checkSignature() {
// 獲取請(qǐng)求參數(shù) $signature = $_GET['signature'];
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
// 驗(yàn)證簽名
$token = 'nRuFZnXwudrpbRv4zXfPvmwmtDLxTSRA';
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
if ($tmpStr == $signature) {
????????if (isset($_GET['echostr'])) {
????????????????return $_GET['echostr'];
????????} else {
????????????????$this->handleMessage();}
????????} else {
????????????????return '簽名驗(yàn)證失敗';
????????}
}?
private function handleMessage() {?
????????$xml = file_get_contents('php://input'); ???????文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-811216.html
????????Log::write($xml, 'wechat_message'); ????????// 解析XML消息文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-811216.html
到了這里,關(guān)于小程序推送公眾號(hào)模板消息的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!