以下代码实现了访问实时报告中的关键词报告功能,最大获取数量5000关键词。
<?php
$arr = array(
"header"=>array("token"=>"",
"username"=>"",
"password"=>""),
"body"=>array ('realTimeRequestTypes'=>array(
"performanceData"=>array("impression","click"),
"startDate"=>"2015-06-16T15:13:00.000",
"endDate"=>"2015-06-16T23:59:59.000",
"levelOfDetails"=>11,
"statRange"=>11,
"unitOfTime"=>8,
"reportType"=>14,
"number"=>5000
)
)
);
$data=json_encode($arr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.baidu.com/json/sms/v3/ReportService/getRealTimeData" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json; charset=utf-8'));
$result=curl_exec ($ch);
print_r(json_decode($result, true));
die();
方法来源:http://dev2.baidu.com/docs.do product=1#page=REST%E9%A3%8E%E6%A0%BC%E7%9A%84API
如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。
如本文对您有用,捐赠和留言 将是对我最好的支持~(捐赠可转为站内积分)
如愿意,请向朋友推荐本站,谢谢。
尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。