百度mip自动推送的PHP代码
分享一段可以自动推送百度mip的PHP代码,可参考的推送链接格式为:您的域名/随机字符/随机字.html;
您可以把这段代码编辑成php格式,只用宝塔自动访问PHP文件即可!
懂代码的可以自行学习看看,循环推送,每次推送100条直到全部推送完毕。
<?php
$server_name = $_SERVER['SERVER_NAME'];
// function rand_str($count = 5)
// {
// $range_array = array_merge(range(0, 9), range('A', 'Z'));
// $str = '';
// foreach ( array_rand($range_array, $count) as $value)
// {
// $str .= $range_array[$value];
// }
// return $str;
// }
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 = 100;
$urls = array();
for ($i = 0; $i < $count; $i++)
{
$urls[] = "http://{$server_name}/".rand_str().'/'.rand_str().'.html';
}
$api = "http://data.zz.baidu.com/urls?site={$server_name}&token=您的token&type=mip";
$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;
?>
获取方式筘薇【25975672】
5年国内白帽SEO技术总监经验,3年在菲黑帽SEO主管技术,100万+网站SEO优化技术,带你3天入门,7天学会,15天掌握,30天精通,快速通过SEO培训赚到钱!任何问题联系微信/QQ:25975672。
» 百度mip自动推送的PHP代码
» 百度mip自动推送的PHP代码