1.新增变量
百度站长平台token:cfg_badutoken
网站域名:cfg_baiduhost
2.
打开:/dede/article_add.php
搜索:
$artUrl = MakeArt($arcID, true, true,$isremote);
if($artUrl=='')
{
$artUrl = $cfg_phpurl."/view.php?aid=$arcID";
}
在下面加入:
else{
$urls[]='http://'.$cfg_baiduhost.'/'.$artUrl;
$api = 'http://data.zz.baidu.com/urls?site='.$cfg_baiduhost.'&token='.$cfg_badutoken;
$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);
}
搜索:
<a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已发布文章管理</u></a>
在下面加入:
<u>百度提交返回".$result."</u>
打开:/dede/article_edit.php
搜索:
$artUrl = MakeArt($arcID, true, true,$isremote);
if($artUrl=='')
{
$artUrl = $cfg_phpurl."/view.php?aid=$arcID";
}
在下面加入:
else{
$urls[]='http://'.$cfg_baiduhost.'/'.$artUrl;
$api = 'http://data.zz.baidu.com/update?site='.$cfg_baiduhost.'&token='.$cfg_badutoken;
$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);
}
搜索:
<a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>管理文章</u></a>
在下面加入:
<u>百度提交返回".$result."</u>
百度站长平台token:cfg_badutoken
网站域名:cfg_baiduhost
2.
打开:/dede/article_add.php
搜索:
$artUrl = MakeArt($arcID, true, true,$isremote);
if($artUrl=='')
{
$artUrl = $cfg_phpurl."/view.php?aid=$arcID";
}
在下面加入:
else{
$urls[]='http://'.$cfg_baiduhost.'/'.$artUrl;
$api = 'http://data.zz.baidu.com/urls?site='.$cfg_baiduhost.'&token='.$cfg_badutoken;
$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);
}
搜索:
<a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已发布文章管理</u></a>
在下面加入:
<u>百度提交返回".$result."</u>
打开:/dede/article_edit.php
搜索:
$artUrl = MakeArt($arcID, true, true,$isremote);
if($artUrl=='')
{
$artUrl = $cfg_phpurl."/view.php?aid=$arcID";
}
在下面加入:
else{
$urls[]='http://'.$cfg_baiduhost.'/'.$artUrl;
$api = 'http://data.zz.baidu.com/update?site='.$cfg_baiduhost.'&token='.$cfg_badutoken;
$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);
}
搜索:
<a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>管理文章</u></a>
在下面加入:
<u>百度提交返回".$result."</u>
完成,最后附加个百度自动推送代码,只需要把以下js做到每个页面的html中即可,自动推送和主动推送可以同时使用,进行互补。
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
版权声明:《 dede主动推送到百度 》为王健原创文章,转载请注明出处!
最后编辑:2019-5-10 18:05:07