: This article mainly introduces the public account development-the question of requesting the server value. if you are interested in the PHP Tutorial, please refer to it. I recently developed a public account and learned some new things. here, I want to help others.
Public function responseMsg () {// $ requestStr = $ _ REQUEST ['mpxml']; // open offline test $ requestStr = $ GLOBALS ["HTTP_RAW_POST_DATA"]; // release if ($ requestStr = '') $ requestStr = file_get_contents (" php: // input "); // open $ 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 for processing packets
$requestStr = $_REQUEST['mpxml'];
Needless to say, accept the value whose name is mpxml.
However, after the server code goes online, this write should fail to accept the request message (in xml format) sent to the server.
$ RequestStr = $ GLOBALS ["HTTP_RAW_POST_DATA"]; // release
Or
$ RequestStr = file_get_contents ("php: // input"); // release
The second method is recommended for request packets that are acceptable to all users. it puts less pressure on the memory and does not require any special php.int settings.
The above introduces the public number development-the question of requesting the value of the server, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.