If you encounter any problems when using php to customize the WeChat Enterprise Account menu, please kindly advise!

Source: Internet
Author: User
If you encounter any problems when using php to customize the enterprise number menu, please kindly advise! There are two files, one response. php is used to respond to messages.
The other is the initial page Sample. php. The problem is that the menu is created, but the message in my response is not resend after I click it. I don't know why.

 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": "Today's songs", "key ": "V1001_TODAY_MUSIC" },{ "type": "click", "name": "Artist Profile", "key": "V1001_TODAY_SINGER" },{ "name ": "Menu", "sub_button": [{"type": "view", "name": "Search", "url ":" http://www.soso.com/ "},{" Type ":" view "," name ":" video "," url ":" http://v.qq.com/ "},{" Type ":" click "," name ":" Like Us "," key ":" V1001_GOOD "}]} '; $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ make_menu_url); curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt ($ ch, success, FALSE ); curl_setopt ($ ch, success, FALSE); curl_setopt ($ ch, CURLOPT_USERAGENT, 'mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0) '); curl_setopt ($ ch, CURLOPT_FOLLOWL OCATION, 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', callback); $ 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 = "developer id :". $ toUsername. "\ n"; $ msg. = "User ID :". $ fromUsername. "\ n"; $ msg. = "event message id :". $ MsgId. "\ n"; $ msg. = "event Message Type id :". $ MsgType. "\ n"; $ msg. = "Event Type :". $ Event. "\ n"; $ msg. = "event KEY value, which corresponds to the KEY value in the custom menu interface :". $ EventKey. "\ n"; $ msg. = "Timestamp when the event is sent :". $ CreateTime. "\ n"; $ msg. = "Message occurrence time :". $ formTime. "\ n";/* $ textTpl ="
 
  %s
  
  %s
  
  
   
% S
  
  %s
  
  %s
  
 "; */$ TextTpl ="
                            
  %s
                             
  %s
                             
  
   
% S
                             
  %s
                             
  %s
                             
  %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 ;}}}?>


It's really depressing. The Enterprise number and service number are a little different.


Reply to discussion (solution)

No matter how you click the menu item, there is no reply. Except for the url type, the webpage will jump normally.

Have you processed the click time of the menu? the keyword key is incorrect .... Php file syntax error or something

Http://www.phpjm.net/encode.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.