Home >Backend Development >PHP Tutorial >PHP uses curl to send json format data example_PHP tutorial

PHP uses curl to send json format data example_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:17:56819browse

Copy code The code is as follows:

$urlcon= 'http://localhost/******.php ';
$data=' {
"button":[
{
"type":"click",
"name":"Today's song",
"key ":"V1001_TODAY_MUSIC"
},
{
"type":"click",
"name":"Singer Profile",
"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);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621687.htmlTechArticleCopy the code as follows: $urlcon= 'http://localhost/******.php' ; $data=' { "button":[ { "type":"click", "name":"Today's song", "key":"V1001_TODAY_MUSIC" }, { "type":"click", "nam. ..
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn