This article mainly introduces PHP using Curl to send JSON format data examples, we refer to the use of the
The code is as follows: $urlcon = ' http://localhost/******.php '; $data = ' {button ': [{' Type ': ' Click ', ' name ': ' Today's song ', ' Key ': ' V1001_today_music '}, {' Type ': ' Click ', ' Name ': ' Introduction to singer ', ' key ' : "V1001_today_singer"}, {"Name": "Menu", "Sub_button": [{"Type": "click", "Name": "Hello word", "key": "V1001_hello_world" }, {"Type": "click", "Name": "Praise 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);