首页  >  文章  >  php教程  >  php curl 发送 json 数据

php curl 发送 json 数据

WBOY
WBOY原创
2016-06-13 10:17:481126浏览

$urlcon= 'http://localhost/******.php';
$data=' {
"按钮":[
{
" type":"click",
"name":"今日歌曲",
"key":"V1001_TODAY_MUSIC"
},
{
"type":"click",
"name":"歌手简介",
"key":"V1001_TODAY_SINGER"
},
{
"name":"菜单",
"sub_button":[
{
"type":"点击",
"name":"hello word",
"key":"V1001_HELLO_WORLD"
},
{
"type ":"点击",
"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);

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn