织梦百度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换成你们自己的表前缀 http://www.conglin.cc/sjcjw_592.html http://www.conglin.cc/sjcjw_593.html http://www.conglin.cc/sjcjw_594.html $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换成你的网址 http://www.conglin.cc/fw_585.html http://www.conglin.cc/fw_586.html http://www.conglin.cc/fw_587.html } $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'), ); http://www.conglin.cc/fw_588.html http://www.conglin.cc/fw_589.html http://www.conglin.cc/fw_590.html http://www.conglin.cc/fw_591.html curl_setopt_array($ch, $options); $result = curl_exec($ch); echo $result.count($urls); ?>复制上面代码