人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

業(yè)界新聞動態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      微信小程序 消息推送php服務(wù)器驗證實例詳解

微信小程序 消息推送php服務(wù)器驗證實例詳解

標簽: 發(fā)布日期:2017-03-30 00:00:00 293

微信小程序 消息推送php服務(wù)器驗證實例詳解

微信文檔(靠下有個“接入指引”):https://mp.weixin.qq.com/debug/wxadoc/dev/api/custommsg/callback_help.html

設(shè)置頁面(“設(shè)置”>>“開發(fā)設(shè)置”):

https://mp.weixin.qq.com/wxopen/initprofile?action=home&lang=zh_CN

1.設(shè)置服務(wù)器域名

比如:https://hosts.com

注意http和https協(xié)議的不同。

2.設(shè)置消息推送

2.1 在你的服務(wù)器里添加服務(wù)器接口test.php,test.php接口內(nèi)容主要是通過token驗證消息是否為微信發(fā)來的,代碼參照官方的例子:

define("TOKEN","xxxxx");/ 后臺填寫的token
$wechatObj = new wechatAPI();
$wechatObj->isValid();
class wechatAPI
{
public function isValid()//驗證微信接口,如果確認是微信就返回它傳來的echostr參數(shù)
{
 $echoStr = $_GET["echostr"];
 if ($this->checkSignature()) {
 echo $echoStr;
 exit;
 }
}
private function checkSignature() //官方的驗證函數(shù)
{
 $signature = $_GET["signature"];
 $timestamp = $_GET["timestamp"];
 $nonce = $_GET["nonce"];
 $token = TOKEN;
 $tmpArr = array($token, $timestamp, $nonce);
 sort($tmpArr, SORT_STRING);
 $tmpStr = implode( $tmpArr );
 $tmpStr = sha1( $tmpStr );
 if( $tmpStr == $signature ){
 return true;
 }else{
 return false;
 }
}
};