Php returns the user text input method, phptext
This example describes how php returns text input. We will share this with you for your reference. The details are as follows:
Obtain the content entered by the user and return the same content concurrently.
// Get post data // $ PostData = $ HTTP_RAW_POST_DATA; $ PostData = file_get_contents ("php: // input"); // determine whether POST is empty if (! $ PostData) {echo "wrong input! "; Exit (0);} // parse the 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; // return if ('text '! = $ MsgType) {// No text. An error message is returned. $ retMsg = "only text messages are supported ";} // else {$ content = $ xmlObj-> Content; $ 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 wildcards in the message $ resultStr = sprintf ($ retTmp, $ fromUserName, $ toUserName, time (), $ retMsg); // output the xml message echo $ resultStr