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 );