What are the problems encountered in the automatic reply to Wechat messages developed by PHP Wechat?
Editor to share with you the PHP Wechat development of Wechat message automatic response to the problems encountered, I believe most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
Wechat reply principle:
When an ordinary Wechat user sends a message to a public account, the Wechat server first receives the message sent by the user
The user information and messages are then packaged into a packet in XML format, and the XML packet is submitted to the URL set by the developer through the POST method.
Question 1: why use $GLOBALS ["HTTP_RAW_POST_DATA"] to save data from POST instead of the $_ POST array?
Answer:
POST can only hold standard data types and cannot be parsed for things like XML, SOAP, or Application/Octet-steam.
While $GLOBALS ["HTTP_RAW_POST_DATA"] and $_ POST are the same, if the data from POST is recognized by PHP, it can be received with $GLOBALS ["HTTP_RAW_POST_DATA"].
Question 2: what are the parameters and return values of simplexml_load_file ()?
Answer:
Parameter meaning
String: the XML string to be processed.
Class: used to specify a new object, usually set to "SimpleXMLElement", to generate a class of simple XML elements.
Options: specifies an additional Libxml parameter, usually set to a constant LIBXML_NOCDATA, which means that CDATA is set as a text node.
Ns: general omission
Is_prefix: general omission
Returns an object of the SimpleXMLElement class when the function is finished.
Function: the official account only accepts text messages and makes corresponding text responses.