php使用curl发送json格式数据实例

代码如下:

$urlcon= ‘http://localhost/******.php’;$data=’ {“button”:[{ “type”:”click”,”name”:”今日歌曲”,”key”:”v1001_today_music”},{“type”:”click”,”name”:”歌手简介”,”key”:”v1001_today_singer”},{“name”:”菜单”,”sub_button”:[{“type”:”click”,”name”:”hello word”,”key”:”v1001_hello_world”},{“type”:”click”,”name”:”赞一下我们”,”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);

http://www.bkjia.com/phpjc/621687.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/621687.htmltecharticle 代码如下: $urlcon= ‘http://localhost/******.php’; $data=’ { “button”:[ { “type”:”click”, “name”:”今日歌曲”, “key”:”v1001_today_music” }, { “type”:”click”, “nam…

Posted in 未分类