DedeCMS5.7百度主動推送PHP代碼,如果,你還是不明白,那。。。。只能幫你到這里了…
這是干貨,懂點代碼的可以自己延伸(保存為任意php文件,放到plus目錄下,訪問看下結(jié)果?)。另外,避免手動提交的麻煩,可以服務(wù)器端設(shè)置個時間每天自動執(zhí)行。
-
<?php
-
require_once(dirname(__FILE__).'/../include/common.inc.php');
-
require_once(DEDEINC."/channelunit.class.php");
-
$whereSql = '';
-
-
$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);
-
$whereSql = "where arc.pubdate<".$dayEnd." AND arc.pubdate>".$dayBegin;
-
$query = "SELECT arc.*,tp.* FROM `2ky_archives` arc
-
LEFT JOIN `2ky_arctype` tp ON arc.typeid=tp.id
-
$whereSql
-
ORDER BY arc.id DESC";
-
-
-
-
$urls = "";
-
$dsql->SetQuery($query);
-
$dsql->Execute();
-
while($row = $dsql->GetArray())
-
{
-
$urls .= "http://www.dedecms51.com".GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
-
$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']).",";
-
}
-
$urls = substr($urls,0,-1);
-
$urls = explode(",",$urls);
-
-
-
-
$api = 'http://data.zz.baidu.com/urls?site=www.dedecms51.com&token=uUGps6ZBwuEYk0LW';
-
$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;
-
?>