Questions about using the POST method to send JSON data

Source: Internet
Author: User
The POST method is used to send JSON data. At the end of this POST, the example of stream_context_create being edited by jxflll in 2015-04-0716: 36: 47 sends a json object using the POST method of this function. Some of them have trouble sending code segments. Thank you. Do not use curl ------ to solve the problem that the POST method is used to send JSON data.

This post was last edited by jxflll at 16:36:47 on

Stream_context_create uses the POST method of this function to send an example of a json object. Some of them have trouble sending code segments. Thank you. Do not use curl
------ Solution ----------------------
I don't know your specific requirements. just give a code snippet.
$ Opts = array (
'Http' => array (
'Method' => 'post ',
'Header' => 'Content-type: application/x-www-form-urlencoded ',
'User _ agent' => $ _ SERVER ['http _ USER_AGENT '],
'Content' => http_build_query ($ data)
)
);

$ Context = stream_context_create ($ opts );
$ Result = file_get_contents ($ url, false, $ context );

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.