php企业号自定义菜单,用php实现微信企业号自定义菜单遇到问题,请大神指点!...
有兩個文件,一個response.php是用來響應(yīng)消息的。
另一個是初始頁面Sample.php。問題在于,我菜單創(chuàng)建出來了,但是點擊之后沒有出現(xiàn)我response里面的消息回發(fā),不知道為什么。
responseMsg();$res = file_get_contents($token_access_url);$arr_result = json_decode($res,true);define("ACCESS_TOKEN",$arr_result['access_token']);$make_menu_url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?access_token=".ACCESS_TOKEN."&agentid=2";$menudata = '{"button":[{ "type":"click", "name":"今日歌曲", "key":"V1001_TODAY_MUSIC" },{ "type":"click", "name":"歌手簡介", "key":"V1001_TODAY_SINGER" },{ "name":"菜單", "sub_button":[{ "type":"view", "name":"搜索", "url":"http://www.soso.com/" },{ "type":"view", "name":"視頻", "url":"http://v.qq.com/" },{ "type":"click", "name":"贊一下我們", "key" :"V1001_GOOD" }] }] }'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $make_menu_url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (compatible; MSIE 5.01;Windows NT 5.0)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_AUTOREFERER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $menudata); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); $info = curl_exec($ch); if(curl_errno($ch)){ echo 'Errno'.curl_error($ch); } curl_close($ch); print_r($info);?>
checkSignature()){ echo $echoStr; exit; } } public function responseMsg() {//get post data, May be due to the different environments$postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; $sendmsg = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=".ACCESS_TOKEN; //extract post data$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $MsgType = $postObj->MsgType; $MsgId = $postObj->MsgId; $Event = $postObj->Event; $EventKey = $postObj->EventKey; $CreateTime = intval($postObj->CreateTime); $formTime = date("Y-m-d H:i:s",$CreateTime); $agentid = $postObj->AgentID; $msg = "開發(fā)者id:".$toUsername."\n"; $msg .= "用戶id:".$fromUsername."\n"; $msg .= "事件消息id:".$MsgId."\n"; $msg .= "事件消息類型id:".$MsgType."\n"; $msg .= "事件類型:".$Event."\n"; $msg .= "事件KEY值,與自定義菜單接口中KEY值對應(yīng):".$EventKey."\n"; $msg .= "事件發(fā)送過來的時間戳:".$CreateTime."\n"; $msg .= "消息發(fā)生具體時間:".$formTime."\n"; /* $textTpl = "%s"; */ $textTpl = "%s %s"; $contentStr = $msg; $resultStr = sprintf($textTpl,$fromUsername,$toUsername,$formTime,$MsgType,$Event,$EventKey, $agentid); echo $resultStr; }private function checkSignature(){ $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = TOKEN;$tmpArr = array($token, $timestamp, $nonce);sort($tmpArr);$tmpStr = implode( $tmpArr );$tmpStr = sha1( $tmpStr );if( $tmpStr == $signature ){return true;}else{return false;}}}?>
真是非常郁悶,企業(yè)號和服務(wù)號還是有點不同的。
回復(fù)討論(解決方案)
菜單項不管怎么點,就是沒有回復(fù)。除了url類型的會正常跳轉(zhuǎn)網(wǎng)頁。
看看 菜單的click時間處理了么, 關(guān)鍵詞 key對不對 。。。。php文件有沒有 語法 錯誤什么的
http://www.phpjm.net/encode.html 本條技術(shù)文章來源于互聯(lián)網(wǎng),如果無意侵犯您的權(quán)益請點擊此處反饋版權(quán)投訴 本文系統(tǒng)來源:php中文網(wǎng)
總結(jié)
以上是生活随笔為你收集整理的php企业号自定义菜单,用php实现微信企业号自定义菜单遇到问题,请大神指点!...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 漏磁用MATLAB,管道漏磁内检测数据可
- 下一篇: oracle用命令方式创建表,oracl