PHP Post JSON data

Source: Internet
Author: User
Tags http post php server

Original link http://www.jb51.net/article/27312.htm

Recently, using Python to interact with PHP, Phthon the JSON data to the PHP, but in PHP $_post not get, $_request can not get, But the request information you see through Firedebug is really the post of the JSON data to PHP, what's the situation

Suddenly think of the previous contact Flash will picture binary stream to PHP, brainwave with $globals[' http_raw_post_data '] get to. The
then looked in depth, the original PHP default only recognizes the application/x-www.form-urlencoded standard data type, therefore, the type such as text/xml or soap or application/ Content such as Octet-stream can not be resolved, if you use the $_post array to receive will fail! So keep the prototype and give it to $globals[' Http_raw_post_data ') to receive it.

PHP http_raw_post_data 
with the Content-type=text/xml type, submit an XML document content to the PHP server, how to get this POST data.  
The raw/uninterpreted HTTP POST information can be accessed with: $GLOBALS [' http_raw_post_data '] this is Usefu L in cases where the post content-type are not something PHP understands (such as text/xml).  
Because PHP is only recognized by default application /x-www.form-urlencoded the standard data type, therefore, the content of the type such as text/xml cannot be parsed into an $_post array, so the prototype is retained and given to $globals[' Http_raw_post_data ') to receive.  
There is also a php://input that can implement this function  
Php://input allows you to read the raw data of the POST. Compared to $HTTP _raw_post_data, it brings less pressure to memory and does not require any special php.ini settings. Php://input cannot be used for enctype= "Multipart/form-data".  

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.