织梦百度php主动推送代码示例,亲试绝对成功!废话不多说,直接上代码。

建议先在命名建立文件为baidu.php,代码如下自己修改

<?php
require_once ("include/common.inc.php");
require_once "include/arc.partview.class.php";
require_once('include/charset.func.php');
$year = date("Y");
$month = date("m");
$day = date("d");
$dayBegin = mktime(0,0,0,$month,$day,$year);//当天开始时间戳
$dayEnd = mktime(23,59,59,$month,$day,$year);//当天结束时间戳
$query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin.""; //这里dede换成你们自己的表前缀
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
$urls.="http://www.51erc.cn".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";
//将上边的http://www.51erc.cn换成你的网址
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls?site=www.51erc.cn&token=VtDwNoCne61ZfPRzh'; // 前边的site换成自己的site xxx换成自己的密钥
$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.count($urls);
?>

然后保存为baidu.php,直接上传到网站的根目录,直接在浏览器输入www.51erc.cn/baidu.php(网址改成自己的) 就能看到主动推送成功!