PHP version of the micro-letter return user text Input method _php tips

Source: Internet
Author: User

This article gives an example of how the PHP version of the micro-letter returns user text input. Share to everyone for your reference, specific as follows:

Get what the user has entered and return the same content

Get POST data//$PostData = $HTTP _raw_post_data;
$PostData = file_get_contents ("Php://input");
  Determines whether the post is an empty if (! $PostData) {echo "wrong input!";
Exit (0);
}//Parse XML string $xmlObj = Simplexml_load_string ($PostData, ' simplexmlelement ', libxml_nocdata);
  if (! $xmlObj) {echo "wrong input!";
Exit (0);
}//Get Data $fromUserName = $XMLOBJ->fromusername;
$toUserName = $XMLOBJ->tousername;
$msgType = $XMLOBJ->msgtype; Returns user input if (' text '!= $msgType) {//Not text, output error message $RETMSG = "Only support text message";//user input text else{$content = $XMLOBJ->con
  Tent
$RETMSG = $content; //output XML template $retTmp = "<xml> <tousername><! [cdata[%s]]></tousername> <fromusername><! [cdata[%s]]></fromusername> <CreateTime>%s</CreateTime> <msgtype><! [cdata[text]]></msgtype> <content><!
[cdata[%s]]></content> <FuncFlag>0</FuncFlag> </xml> "; Replace the wildcard character in the message $RESULTSTR = SPRintf ($RETTMP, $fromUserName, $toUserName, Time (), $RETMSG);

 Message echo for output XML $RESULTSTR

For more information on PHP related content readers can view the site topics: "PHP micro-credit Development Skills summary", "PHP coding and transcoding Operation skills Summary", "PHP Network Programming Skills Summary", "PHP basic Grammar Introductory Course", "PHP string (String) Usage Summary", "php+ MySQL Database operations Introduction tutorial and PHP Common database operation Skills Summary

I hope this article will help you with the PHP program design.

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.