织梦后台文档主动百度推送熊掌推送批量推送

资源来源网络,如需授权,请更换源码,模块仅供学习,如需商用请购买正版授权,本栏目不提供技术服务,积分不够请签到!如何签到?系统升级暂停签到,恢复关注公告!
如遇下载链接蓝奏网盘打不开lanzous替换成lanzoux尝试! 广告


环境要求

PHP必须开启了curl扩展

百度主动推送(实时)可以缩短百度爬虫发现您站点新链接的时间,使新发布的页面可以在领先时间被百度收录

织梦程序我们可以在后台添加文档完成那一刻即时主动推送到百度或熊掌,也可以在后台文档列表里批量推送
最终效果

织梦百度主动推送教程

1、织梦网站后台-系统-基本参数,添加新变量,如果变量值未填写或者为空将不推送

变量名称

cfg_baidu_push

参数说明

百度推送接口

变量值

登录你的百度平台 https://ziyuan.baidu.com 获取接口调用地址

如图,注意你的站点域名要对应上

添加好变量是这样的

2、打开 /dede(后台目录)/inc/inc_archives_functions.php 在文件最末尾插入

/**
* 百度主动推送
*/
function baidu_push($id=””,$qstr=””)
{
global $cfg_multi_site,$cfg_basehost,$cfg_baidu_push;
if(!empty($id) && !empty($cfg_baidu_push))
{
if( !empty($id) && empty($qstr) ) $qstr = $id;
if($qstr==”)
{
exit();
}
$qstrs = explode(‘`’,$qstr);
$cfg_domain = $cfg_multi_site == ‘N’ ? $cfg_basehost : ”;
$urls = array();
$i = 0;
foreach($qstrs as $aid)
{
$i++;
$arcrow = GetOneArchive($aid);
$url = $cfg_domain.$arcrow[‘arcurl’];
$urls[] = $url;
$artlist .= $url.”<br />”;
}
if($i>1) $artlist = “”;
if(!empty($urls)){
$ch = curl_init();
$options = array(
CURLOPT_URL => trim($cfg_baidu_push),
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);
curl_close($ch);
$result = json_decode($result, true);
if(isset($result[‘success’])){
$not_same_site = isset($result[‘not_same_site’][0]) ? ” <font style=’color:#f00;’>推送链接与百度绑定站点不一致</font> ” : “”;
$not_valid = isset($result[‘not_valid’][0]) ? ” <font style=’color:#f00;’>推送链接不合法</font> ” : “”;
return $not_same_site . $not_valid . ‘百度主动推送成功 ‘.$result[‘success’].’ 条!当天剩余 ‘.$result[‘remain’].’ 条可推送!’.$artlist;
}else{
return ‘百度主动推送失败,错误码:’.$result[‘error’].'<a href=https://ziyuan.baidu.com/college/courseinfo?id=267&page=2#h2_article_title12 target=_blank>详情</a>’;
}
}
return “没有数据被推送!”;
}
}

3、找到后台文档发布程序PHP文件

【普通文章】模型的是
/dede/article_add.php
【图片集】模型的是
/dede/album_add.php
【软件】模型的是
/dede/soft_add.php
【商品/自定义模型】模型的是
/dede/archives_add.php

根据你的需要在对应的php文件中找到

//返回成功信息

在它上面加入

if(!empty($cfg_baidu_push))
{
$backurl .= “<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;”.baidu_push($arcID).”</p>”;
}

继续找到

line-height:36px;height:36px

改成

line-height:36px;

修改完后如图这样

至此,织梦发布文档主动推送到百度功能完成。

需要做熊掌主动推送(实时)的小伙伴往下看
织梦熊掌主动推送教程

1、织梦网站后台-系统-基本参数,添加新变量,如果变量值未填写或者为空将不推送

变量名称

cfg_xiong_push

参数说明

熊掌推送接口

变量值

登录你的百度平台 https://ziyuan.baidu.com/ydzq/ 获取接口调用地址

如图,天级收录和周级收录都可以

注意你的站点域名已绑定上熊掌id

添加好变量是这样的

2、打开 /dede(后台目录)/inc/inc_archives_functions.php 在文件最末尾插入

/**
* 熊掌主动推送
*/
function xiong_push($id=””,$qstr=””)
{
global $cfg_multi_site,$cfg_basehost,$cfg_xiong_push;
if(!empty($id) && !empty($cfg_xiong_push))
{
if( !empty($id) && empty($qstr) ) $qstr = $id;
if($qstr==”)
{
exit();
}
$qstrs = explode(‘`’,$qstr);
$cfg_domain = $cfg_multi_site == ‘N’ ? $cfg_basehost : ”;
$urls = array();
$i = 0;
foreach($qstrs as $aid)
{
$i++;
$arcrow = GetOneArchive($aid);
$url = $cfg_domain.$arcrow[‘arcurl’];
$urls[] = $url;
$artlist .= $url.”<br />”;
}
if($i>1) $artlist = “”;
if(!empty($urls)){
$ch = curl_init();
$options = array(
CURLOPT_URL => trim($cfg_xiong_push),
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);
curl_close($ch);
$result = json_decode($result, true);
if(isset($result[‘error’])){
return ‘熊掌主动推送失败,错误码:’.$result[‘error’].’ message:’.$result[‘message’];
}else{
$not_same_site = isset($result[‘not_same_site’][0]) ? ” <font style=’color:#f00;’>推送链接与熊掌绑定站点不一致</font> ” : “”;
$not_valid = isset($result[‘not_valid’][0]) ? ” <font style=’color:#f00;’>推送链接不合法</font> ” : “”;
return $not_same_site . $not_valid . ‘熊掌主动推送成功 ‘.$result[‘success_batch’].$result[‘success_realtime’].’ 条!当天剩余 ‘.$result[‘remain_batch’].$result[‘remain_realtime’].’ 条可推送!’.$artlist;
}
}
return “没有数据被推送!”;
}
}

3、找到后台文档发布程序PHP文件

【普通文章】模型的是
/dede/article_add.php
【图片集】模型的是
/dede/album_add.php
【软件】模型的是
/dede/soft_add.php
【商品/自定义模型】模型的是
/dede/archives_add.php

根据你的需要在对应的php文件中找到
1

//返回成功信息

在它上面加入

if(!empty($cfg_xiong_push))
{
$backurl .= “<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;”.xiong_push($arcID).”</p>”;
}

继续找到,如果你前面已经删除过height:36px,可以跳过这一步

line-height:36px;height:36px

改成

line-height:36px;

修改完后

至此,织梦发布文档主动推送到熊掌功能完成。

需要批量推送的小伙伴请继续往下看
织梦后台文档列表添加批量推送至百度/推送至熊掌

批量推送实现教程

在加入批量之前必须完成上面的【织梦百度主动推送教程】第1、第2步 和 【织梦熊掌主动推送教程】第1、第2步,否则以下教程无效

1、打开 /dede/templets/content_list.htm (软件模型和自定义模型是 /dede/templets/content_i_list.htm) 找到
1

删除属性

这一行,在它下面添加

<a href=”javascript:baidu_push(0)” class=”coolbg”>&nbsp;推送至百度&nbsp;</a>
<a href=”javascript:xiong_push(0)” class=”coolbg”>&nbsp;推送至熊掌&nbsp;</a>
<script type=”text/javascript”>
function baidu_push(aid)
{
var qstr=getCheckboxItem();
if(aid==0) aid = getOneItem();
location=”archives_do.php?aid=”+aid+”&dopost=baidu_push&qstr=”+qstr;
}
function xiong_push(aid)
{
var qstr=getCheckboxItem();
if(aid==0) aid = getOneItem();
location=”archives_do.php?aid=”+aid+”&dopost=xiong_push&qstr=”+qstr;
}
</script>

2、打开 /dede/archives_do.php 找到末尾一行的

?>

在它上面加入

else if($dopost==’baidu_push’)
{
if( !empty($aid) && empty($qstr) ) $qstr = $aid;

if($qstr==”)
{
ShowMsg(‘参数无效!’,$ENV_GOBACK_URL);
exit();
}
require_once(DEDEADMIN.’/inc/inc_archives_functions.php’);
$result = baidu_push($qstr);
ShowMsg($result,$ENV_GOBACK_URL,0,5000);
exit();
}
else if($dopost==’xiong_push’)
{
if( !empty($aid) && empty($qstr) ) $qstr = $aid;

if($qstr==”)
{
ShowMsg(‘参数无效!’,$ENV_GOBACK_URL);
exit();
}
require_once(DEDEADMIN.’/inc/inc_archives_functions.php’);
$result = xiong_push($qstr);
ShowMsg($result,$ENV_GOBACK_URL,0,5000);
exit();
}

批量推送教程完成。

©下载资源版权归作者所有;本站所有资源均来源于网络,仅供学习使用,请支持正版!
风格酷模板网 » 织梦后台文档主动百度推送熊掌推送批量推送
NOTICE:【咨询风格酷】客服QQ:1131734965
NOTICE:【咨询风格酷】客服微信:wwwxmamnet
NOTICE:【风格酷模板网②群】QQ群:288678775
☉免责声明:本站所有模板均来自用户分享和网络收集,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服,我们核实后会立即删除。
☉如果源码网盘地址失效!或有其他问题,请点我报错,谢谢合作!
☉人民币与积分汇率为1比10,即1元=10积分.有任何疑问请联系客服
☉如有其他问题,请加网站客服QQ(1131734965)进行交流。
☉本站提供的源码、模板、软件工具等其他资源,都不包含技术服务,请大家谅解!
☉源码、模板等资源会随着技术、环境的升级而存在部分问题,还请慎重选择。

发表评论

风格酷模板网www.xmam.net分享优质网站模板

立即查看 了解详情