How does Php use curl to send data instances in json format?

Source: Internet
Author: User
This section describes how Php can use curl to send instance documents in json format for free download. Abstract: php: How to Use curl to send data in json format instance this article mainly introduces php instances that use curl to send data in json format. For details, refer to the following code: $ urlconh How does Php use curl to send data instances in json format?

How does Php use curl to send data instances in json format?

This article mainly introduces php instances that use curl to send json data. For more information, see the following code:

$ Urlcon = 'HTTP: // localhost/******. php ';

$ Data = '{

"Button ":[

{

"Type": "click ",

"Name": "Today's songs ",

"Key": "V1001_TODAY_MUSIC"

},

{

"Type": "click ",

"Name": "Introduction to singers ",

"Key": "V1001_TODAY_SINGER"

},

{

"Name": "menu ",

"Sub_button ":[

{

"Type": "click ",

"Name": "hello word ",

"Key": "V1001_HELLO_WORLD"

},

{

"Type": "click ",

"Name": "like us ",

"Key": "V1001_GOOD"

}]

}]

}';

$ Host = $ urlcon;

$ Ch = curl_init ();

$ Data = 'data = '. $ data;

Curl_setopt ($ ch, CURLOPT_POST, 1 );

Curl_setopt ($ ch, CURLOPT_HEADER, 0 );

Curl_setopt ($ ch, CURLOPT_URL, $ host );

Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );

Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data );

Echo $ output = curl_exec ($ ch );

Curl_close ($ ch );

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.