当前位置: > 教程分享 > 百度站长平台主动推送链接php版(帝国cms)

百度站长平台主动推送链接php版(帝国cms)

新建一个ping.php文件,将下列代码写入文件并上传到服务器。

<?php
$link=mysql_connect("localhost","root","lalalademaxiya");
mysql_select_db("manmanman", $link);
$sql = "SELECT id FROM `phome_ecms_news` order by id desc limit 3001, 1000";//取出数据库里面从3001开始的1000条数据
$resultid = mysql_query($sql, $link); // 执行查询语句
while ($idinfo = mysql_fetch_array($resultid)){ //返回查询结果到数组

$newid = $idinfo["id"]; //将数据从数组取出
$urls[] =  "http://www.vpszn.com/item/".$newid.".html";  //输出数据
}
$api = 'http://data.zz.baidu.com/urls?site=www.vpszn.com&token=你的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;
?>

百度站长平台主动推送链接php版(帝国cms):等您坐沙发呢!

发表评论

表情
还能输入210个字