帝國cms7.2百度實時主動推送插件(半自動)

百度收錄一直是站長最最關心的問題,怎麼自動推送給百度收錄,百度到底有沒有收錄,收錄多少了,那些還未收錄?這個問題下面一一

作答,自家使用插件獨家首發 自己網站使用,現在分享給大家啦!

第一步:添加自定義函數

打開 e/class/userfun.php 添加自定義函數:

//發送給百度時時更新-------------------------------

function user_PostBaiduSitemap($id,$_urls){

$site = 'www.qutonghua.com';//你的網站域名

$token = 'xxxxxxx';//百度給的token

$count = count($id);

if (empty($count))

{

printerror("未選擇信息ID", "", 1, 0, 1);

}

$urls=array();

for($i=0;$i

{

$id[$i] = (int)$id[$i];

if (array_key_exists($id[$i],$_urls)){

$urls[] = $_urls[$id[$i]];

}

}

$api = "http://data.zz.baidu.com/urls?site=$site&token=$token";

$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);

$httpstat = curl_getinfo($ch,CURLINFO_HTTP_CODE);

curl_close($ch);

if($httpstat==200){

$obj = json_decode($result);

printerror("今天剩餘{$obj->remain}條,成功提交{$obj->success}條", "", 1, 0, 1);

}else{

printerror('推送失敗', "", 1, 0, 1);

}

}

第二步: 添加對接函數

打開 e/admin/ecmsinfo.php 查找 elseif($enews=="EditNews") 大約46行左右,插入內容如下:

帝國cms7.2百度實時主動推送插件(半自動)

代碼:

elseif($enews=="Post_Baidu_sitemap")//文章實時發送百度

{

$id=$_POST['id'];

$urls=$_POST['titleurl'];

User_PostBaiduSitemap($id,$urls);

}

第三步:添加按鈕

打開:e/data/html/list/listinfo.php 這個文件。

大約324行

代碼前面添加按鈕:

即可。

帝國cms7.2百度實時主動推送插件(半自動)

是不是很簡單呢?


分享到:


相關文章: