PHP版比较好弄。因为百度已经给了我们示例了,照抄就行了啊关键点在这个array这里。设置
PHP版比较好弄。因为百度已经给了我们示例了,照抄就行了啊
关键点在这个array这里。设置好了,一般都能成功!
PHP百度主动推送代码范例
$urls = array(
'http://www.xxx.com/xxx/xxx.html',
'http://www.xxx.com/xxx/xxx.html',
);
$api = 'http://data.zz.baidu.com/urls?site=www.xxx.com&token=xxxxxx;
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode("\n", $urls),
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;