PHP百度推送代码(泛目录版)

Real dream is the other shore of reality.
真正的梦就是现实的彼岸

【活动】:会员128元永久会员早开早划算!

PHP百度推送代码(泛目录版)

最近在玩泛目录,查看源码的时候发现了一个不错的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;
$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;

PHP百度推送代码(泛目录版)
------本页已结束,新年特惠限时98元尊贵特权------

感谢您的来访,获取更多精彩文章请收藏本站。

anything that adds laughter and joy to your life.
不要延迟任何可以给你的生活带来欢笑与快乐的事情
© 版权声明
THE END
点赞11打赏 分享
Misery can be caused by someone being just weak and indecisive.
一个人仅仅因为软弱无能或优柔寡断就完全可能招致痛苦
评价 抢沙发

请登录后发表评论

    暂无评论内容