最近在玩泛目录,查看源码的时候发现了一个不错的Baidu推送脚本,分享一下
$server_name = $_SERVER['SERVER_NAME'];
function rand_str($length = 5)
{
$str = '';
$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
$max = strlen($strPol)-1;
for($i = 0; $i < $length; $i++)
{
$str .=$strPol[rand(0,$max)];
}
return $str;
}
$count = 10; //推送数量
$urls = array();
for ($i = 0; $i < $count; $i++)
{
$urls[] = "http://www.xxx.com/".rand_str().".html"; //推送的网址
}
$api = "http://data.zz.baidu.com/urls?site=www.xxx.com&token=xxx"; //百度推送api
$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;
代码不多解释了,用法懂得都懂,上传到服务器访问一下即可,源码y’h已经加上一些简单注释
生成随机网址后缀,一次推送十条,想修改推送数量修改 $count = 10;
© 版权声明
THE END
暂无评论内容