WeChat debugging problems

Source: Internet
Author: User
Tags php define
How does the keyword server receive the logic output ?? For example, if I receive xml data and output it, but sometimes I need to write an array and then how to output it?

If only xml and string files and database tables can be written, the array cannot be output.


Reply to discussion (solution)

I tried it. I wrote all the response conditions for Guan jianzi in the code and set it to death. I didn't do it in the database ..

 FromUserName; $ toUsername = $ postObj-> ToUserName; $ keyword = trim ($ postObj-> Content); $ key = $ Msg-> match ($ rule, $ keyword ); # When the cycle starts, determine the message sent by the user. the parameter serves to switch ($ key) {case "quiz": $ Msg-> picMsg ($ fromUsername, $ toUsername, "Hechuang Yingfeng launched: free four-digit quiz, with a pay-as-you-go fee of 300 RMB! "," http://www.hcyf07.com /Weixin/sdd2.jpg ", 'Quiz '," http://www.hcyf07.com "); Exit (); case" bidding call fee ": $ Msg-> picMsg ($ fromUsername, $ toUsername," Hechuang Yingfeng online ticket: free four-digit quiz, 300 yuan on the phone! "," http://www.hcyf07.com /Weixin/sdd2.jpg ", 'Call fees for bidding '," http://www.hcyf07.com "); Exit (); case" call fee ": $ Msg-> picMsg ($ fromUsername, $ toUsername," Hechuang Yingfeng online ticket: free four-digit quiz, 300 yuan on the phone! "," http://www.hcyf07.com /Weixin/sdd2.jpg ", 'Call payby '," http://www.hcyf07.com "); Exit (); case" quiz silver ": $ Msg-> picMsg! "," http://www.hcyf07.com /Weixin/sdd2.jpg ", 'Quiz Baiyin '," http://www.hcyf07.com "); Exit (); default: $ Msg-> txtMsg ($ fromUsername, $ toUsername, $ default);} if (! Empty ($ keyword) {$ msgType = "text"; // Check the received keyword echo $ resultStr ;} else {if ($ event = "subscribe") {// Follow $ msgType = "text" for the first time; $ url =" http://www.bjcy07.com/ "; $ ContentStr =" Hello, thank you for choosing Beijing Hechuang Yingfeng Commodity Management Co., Ltd.. Beijing Hechuang Yingfeng Commodity Management Co., Ltd. is a member of the Beijing Commodity Exchange (member seat No. 007 ), with the sale and repurchase of precious metals such as spot silver as the main business project, the company implements 24-hour trading quotation transactions and provides precious metal investment consulting services. ". $ Url; $ resultStr = sprintf ($ textTpl, $ fromUsername, $ toUsername, $ time, $ msgType, $ contentStr); echo $ resultStr;} echo "Input something... ";}/* class of msg */class Msg {public function valid () {$ echoStr = $ _ GET [" echostr "]; // valid signature, option if ($ this-> checkSignature () {echo $ echoStr; exit ;}# source user, sent to user, time, title, image address, description, click the link when the message is sent. of course, you can modify this sequence function picMsg ($ fromUsername, $ toUsername, $ title, $ PicUrl, $ Discription, $ Url) {// get post data, may be due to the different environments $ postStr = $ GLOBALS ["HTTP_RAW_POST_DATA"]; $ time = time (); $ textTpl ="
  
  %s
   
  %s
   
  
   
% S
   
  news
   
   
  1  
  
   <! [CDATA [% s]> 
   %s
    
   %s
    
   %s
   
    
  
   
1
   
 "; $ ResultStr = sprintf ($ textTpl, $ fromUsername, $ toUsername, $ time, $ title, $ Discription, $ PicUrl, $ Url); echo $ resultStr ;} function txtMsg ($ fromUsername, $ toUsername, $ contentStr) {$ postStr = $ GLOBALS ["HTTP_RAW_POST_DATA"]; $ time = time (); $ textTpl ="
  
  %s
   
  %s
   
  
   
% S
   
  text
   
  %s
   
  
   
0
    
   
  
 "; $ ResultStr = sprintf ($ textTpl, $ fromUsername, $ toUsername, $ time, $ contentStr); 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 {re Turn false ;}# match the user's keyword function match ($ rule, $ keyword) {$ num = count ($ rule) + 1; for ($ I = 0; $ I <$ num; $ I ++) {if (preg_match ("/$ rule [$ I]/", $ keyword) {return $ rule [$ I]; exit () ;}}}?>

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.