本文最后更新于 1181 天前,其中的信息可能已经有所发展或是发生改变。
官方的代码
$urls = array(
'http://www.example.com/1.html',
'http://www.example.com/2.html',
);
$api = 'http://data.zz.baidu.com/urls?site=https://www.2331314.xyz&token=**填你自己的token**';
$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;
优化后
意思就是将当前访问的页面推送至收录
<?php
$urls = array(
'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],
);
$api = 'http://data.zz.baidu.com/urls?site=https://www.2331314.xyz&token=**填你自己的token**';
$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;
?>