WeChat public number development---WeChat request service end value problem

Source: Internet
Author: User
Recently developed the public number, learned something new, in this record, but also hope to help others

Public functionresponsemsg()    {//$requestStr = $_request[' mpxml '); Off-line test release$requestStr=$GLOBALS["Http_raw_post_data"];//Online releaseif($requestStr=='')$requestStr= File_get_contents ("Php://input");//Online release$this-Log-Output(' req ', "Request Message".$requestStr);if(!Empty($requestStr)) {$POSTOBJ= Simplexml_load_string ($requestStr, ' SimpleXMLElement ', Libxml_nocdata);$fromUsername=$POSTOBJ-Fromusername;$toUsername=$POSTOBJ-Tousername;$msgType=$POSTOBJ-Msgtype;$keyword= Trim ($POSTOBJ-Content);$arr=Array(' Fromusername '=$fromUsername, ' Tousername '=$toUsername, ' Msgtype '=$msgType,' keyword '=$keyword, ' Postobj '=$POSTOBJ);$responseStr=$this-Controllers-Index($arr);$this-Log-Output(' Res ', "Response message".$responseStr);Echo$responseStr;}Else{Echo'';Exit;}    }

The above is part of the code to process the message

It's needless to say, accept the value of name mpXML.

However, after the service-side code is on-line, this should not be accepted to the sending server's request message (XML format).

$GLOBALS ["Http_raw_post_data"] ; //Online release
Or
= file_get_contents ("Php://input"); //Online release
can accept the request message, the second method is recommended, it brings less pressure to memory, and does not require any special php.int settings

The above introduces the public number development---Request service end value problem, including the content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.