DedeCMS5.7百度主动推送PHP代码,如果,你还是不明白,那。。。。只能帮你到这里了… 
这是干货,懂点代码的可以自己延伸(保存为任意php文件,放到plus目录下,访问看下结果?)。另外,避免手动提交的麻烦,可以服务器端设置个时间每天自动执行。 
织梦dedeCMS5.7非实时百度主动推送
<?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.dede58.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 url换成自己的,站长工具里有 
  
$api = 'http://data.zz.baidu.com/urls?site=www.dede58.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; 
?>

发表评论

后才能评论