關注公眾號事件沒反應
public?function?index(){ //獲得參數?signature?nonce?token?timestamp?echostr $nonce?????=?$_GET['nonce']; $token?????=?'weixin'; $timestamp?=?$_GET['timestamp']; $echostr???=?$_GET['echostr']; $signature?=?$_GET['signature']; //形成數組,然后按字典序排序 $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->reponseMsg(); } } //?接收事件推送并回復 public?function?reponseMsg(){ //1.獲取到微信推送過來post數據(xml格式) $postArr?=?file_get_contents('php://input'); $postObj?=?simplexml_load_string($postArr); //判斷該數據包是否是訂閱的事件推送 if(?strtolower(?$postObj->MsgType)?==?'event'){ //如果是關注?subscribe?事件 if(?strtolower($postObj->Event?==?'subscribe')?){ //回復用戶消息(純文本格式) $toUser???=?$postObj->FromUserName; $fromUser?=?$postObj->ToUserName; $time?????=?time(); $msgType??=??'text'; $content??=?'歡迎關注我們的微信公眾賬號'; $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; } } }//reponseMsg?end
這是我的代碼,微信新關注用戶沒有回復,同學們幫我看看吧
2017-08-05
現在解決了嗎,我也是這么敲的,跟你幾乎一模一樣。搞了兩天了還是沒解決
2017-07-07
半年過去了,我還是沒有解決此問題。。。。我覺得我可能得改行
2017-02-14
初學者表示遇到同樣的問題,請問你的是怎么解決的
2016-12-05
新手的我表示看不出來。。抱歉