织梦DedeCMS后台添加一键推送百度站长、MIP、熊掌号功能

分类:建站教程 时间:2024-12-22 19:00 浏览:0 评论:0
0

织梦DedeCMS网站一键推送功能有利于搜索引擎蜘蛛在第一时间抓取到网站的最新内容,加快收录速度。


织梦DedeCMS后台添加一键推送百度站长、MIP、熊掌号功能


第一步:百度站长、MIP、移动推送

在织梦后台目录(默认为dede),新建一个baidu.php文件,放入以下代码。

Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
    $urls.="http://www.demo.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; // http://www.demo.com 换成你们自己的域名 
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls?site=www.demo.com&token=********'; // 前边的api换成自己的推送 API
$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.count($urls);
?>

注意:上面有三个注释的地方,要改成自己的。

其他MIP推送、移动推送同理,多新建几个PHP,更换下域名和API推送接口即可。

第二步:熊掌号推送

熊掌号只能推送当天更新的数据,所以要代码跟上面的有点不一样,要加个时间限制。

在织梦后台目录(默认为dede),新建一个xz.php文件,放入以下代码。

".$dayBegin.""; //这里dede换成你们自己的表前缀
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
    $urls.="http://www.demo.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; // http://www.demo.com 换成你们自己的域名
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls?appid=****&token=***&type=realtime'; // 前边的api换成自己的推送 API
$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.count($urls);
?>

第三步:在织梦后台添加推送菜单

打开/dede/inc/inc_menu.php,大概136行下面添加刚刚新建的PHP文件


织梦DedeCMS后台添加一键推送百度站长、MIP、熊掌号功能



测试

织梦DedeCMS后台添加一键推送百度站长、MIP、熊掌号功能


显示success,则说明功能正常。


1. 本站所有资源来源于用户上传或网络,仅作为参考研究使用,如有侵权请邮件联系站长!
2. 本站积分货币获取途径以及用途的解读,想在本站混的好,请务必认真阅读!
3. 本站强烈打击盗版/破解等有损他人权益和违法作为,请各位会员支持正版!
4. 建站教程 > 织梦DedeCMS后台添加一键推送百度站长、MIP、熊掌号功能

用户评论

function fuckyou() { window.close(); window.location = "about:blank"; } function ck() { console.profile(); console.profileEnd(); if (console.clear) { console.clear() }; if (typeof console.profiles == "object") { return console.profiles.length > 0; } } function hehe() { if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || ( typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) { fuckyou(); } if (typeof console.profiles == "object" && console.profiles.length > 0) { fuckyou(); } } hehe(); window.onresize = function() { if ((window.outerHeight - window.innerHeight) > 200) fuckyou(); }