public?function?index()
????{
????????//獲得參數(shù)?signature?nonce?token?timestamp?echostr
????????$nonce?=?$_GET['nonce'];
????????$token?=?'weichat';
????????$timestamp?=?$_GET['timestamp'];
????????$echostr?=?$_GET['echostr'];
????????$signature?=?$_GET['signature'];
????????//形成數(shù)組,然后按字典序排序
????????$array?=?array();
????????$array?=?array($nonce,?$timestamp,?$token);
????????sort($array);
????????//拼接成字符串,sha1加密?,然后與signature進行校驗
????????$str?=?sha1(implode($array));
????????if?($str?==?$signature?&&?$echostr)?{
????????????//第一次接入weixin?api接口的時候
????????????echo?$echostr;
????????????exit;
????????}?else?{
????????????$this?->?responseMsg();
????????}
????}
????public?function?responseMsg()
????{
????????$postArr?=?$GLOBALS['HTTP_RAW_POST_DATA'];
????????$postObj?=?simplexml_load_string($postArr);
????????if(strtolower($postObj->Event?==?'subscribe')){
????????????//回復(fù)用戶消息(純文本格式)?
????????????$toUser???=?$postObj->FromUserName;
????????????$fromUser?=?$postObj->ToUserName;
????????????$time?????=?time();
????????????$msgType??=??'text';
????????????$content??=?'歡迎關(guān)注我們的微信公眾賬號'.$postObj->FromUserName.'-'.$postObj->ToUserName;
????????????$template?=?"<xml>
????????????????????????<ToUserName><![CDATA[%s]]></ToUserName>
????????????????????????<FromUserName><![CDATA[%s]]></FromUserName>
????????????????????????<CreateTime>%s</CreateTime>
????????????????????????<MsgType><![CDATA[%s]]></MsgType>
????????????????????????<Content><![CDATA[%s]]></Content>
????????????????????????</xml>";
????????????$info?????=?sprintf($template,?$toUser,?$fromUser,?$time,?$msgType,?$content);
????????????echo?$info;
????????}
????}
2017-08-15
用日志輸出看一哈,我也同樣問題,現(xiàn)在沒有解決。
2017-06-14
關(guān)鍵是那自己的網(wǎng)址我都試了不行 為什么呢 你們有沒有解決