php使用curl发送json格式数据实例
php使用curl发送json格式数据实例
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:$urlcon='http://localhost/******.php';$data='{"button":[{"typ...

复制代码 代码如下:

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类