This article mainly introduces php instances that use curl to send json data.
The Code is as follows:
$ 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 );