正文

織夢(mèng)DedeCMS發(fā)布文章后主動(dòng)推送給百度(實(shí)時(shí)推送)

后臺(tái)系統(tǒng)參數(shù)新建字段

cfg_bdtoken:百度接口

cfg_bdhost:推送域名

修改相關(guān)PHP文件

打開/dede/article_add.php

找到

$artUrl = MakeArt($arcID,true,true,$isremote);

if($artUrl=='')

{

$artUrl = $cfg_phpurl."/view.php?aid=$arcID";

}

在下面加入

else{

$urls[]='http://'.$cfg_bdhost.''.$artUrl;//如果網(wǎng)站開啟了SSL,請(qǐng)把http改成https

$api = $cfg_bdtoken;

$ch = curl_init();

$options =array(

CURLOPT_URL => $api,

CURLOPT_POST => true,

CURLOPT_RETURNTRANSFER => true,

CURLOPT_POSTFIELDS => implode(" ", $urls),

CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),

);

curl_setopt_array($ch, $options);

$result = curl_exec($ch);

}

繼續(xù)找到

<a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已發(fā)布文章管理</u></a>

在下面加入

<a href=''><u>百度提交返回".$result."</u></a>

&nbsp;&nbsp;

保存。

繼續(xù)操作,打開/dede/article_edit.php

找到

$artUrl = MakeArt($id,true,true,$isremote);

if($artUrl=='')

{

$artUrl = $cfg_phpurl."/view.php?aid=$id";

}

在下面加入

else{

$urls[]='http://'.$cfg_bdhost.''.$artUrl;//如果網(wǎng)站開啟了SSL,請(qǐng)把http改成https

$api = $cfg_bdtoken;

$ch = curl_init();

$options =array(

CURLOPT_URL => $api,

CURLOPT_POST => true,

CURLOPT_RETURNTRANSFER => true,

CURLOPT_POSTFIELDS => implode(" ", $urls),

CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),

);

curl_setopt_array($ch, $options);

$result = curl_exec($ch);

}

繼續(xù)找到

<a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>管理文章</u></a>

在下面加入

<a href=''><u>百度提交返回".$result."</u></a>

&nbsp;&nbsp;

完成,發(fā)布文章和更新文章都實(shí)現(xiàn)百度主動(dòng)推送了。

聲明:月季網(wǎng)致力月季產(chǎn)業(yè),部分文字和圖片來(lái)源網(wǎng)絡(luò),版權(quán)歸原作者,如有侵權(quán)請(qǐng)聯(lián)系刪除。

月季網(wǎng)

月季網(wǎng)