In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "php Wechat can not receive post data how to solve", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn how to solve the problem that php Wechat can't receive post data.
Php Wechat can not receive post data solution: 1, open register_globals;2 in php.ini, through the file_get_contents ("php://input") method to obtain post data.
This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer.
What if php Wechat can't receive post data?
The official PHP API of Wechat cannot obtain postStr data.
In the PHP interface document officially provided by Wechat, there is such a code for dealing with major business.
Public function getIndex () {if (ob_get_contents ()) ob_end_clean (); $postStr = isset ($GLOBALS ["HTTP_RAW_POST_DATA"])? $GLOBALS ["HTTP_RAW_POST_DATA"]:''; / / get data from post if (! empty ($postStr)) {$postObj = simplexml_load_string ($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $this- > postObj = $postObj $this- > fromUserName = $postObj- > FromUserName;// sender $this- > toUserName = $postObj- > ToUserName;// receiver (i.e. this public account) $this- > msgType = trim ($postObj- > MsgType); / / message type $this- > content = trim ($postObj- > Content); $this- > event = trim ($postObj- > Event); $this- > eventKey = trim ($postObj- > EventKey); $this- > dealMsg () } else {$this- > wx- > makeInfo (Input::all ()); $this- > wx- > valid (); / / for non-message push, the default is check} flush ();}
This method uses GLOBALS as a global variable to get the original Post data, but this method also has problems.
To get data through Globals, register_globals in php.ini must be set to ON. In the lower version of php, register data is on by default, but in the higher version, it is closed by default. This is because, after being set to ON, the variable submitted by the form will automatically become a variable, that is, all the variables entered in the address bar will become global variables, which is very insecure.
In addition to $GLOBALS ["HTTP_RAW_POST_DATA"] to get data from post, you can also get data from post through file_get_contents ("php://input") method.
At this point, I believe that everyone on the "php Wechat can not receive post data how to solve" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.