百度熊掌推送php源码,织梦百度熊掌主动推送教程

织梦百度熊掌主动推送可以缩短百度爬虫发现您站点新链接的时间,使新发布的页面可以在第一时间被百度收录,织梦程序我们可以在后台添加文档完成那一刻即时主动推送到百度或熊掌,也可以在后台文档列表里批量推送

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

变量名称

cfg_xiong_push

参数说明

熊掌推送接口

变量值

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

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."
";

}

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]) ? " 推送链接与熊掌绑定站点不一致 " : "";

$not_valid = isset($result['not_valid'][0]) ? " 推送链接不合法 " : "";

return $not_same_site . $not_valid . '熊掌主动推送成功 '.$result['success_batch'].' 条!当天剩余 '.$result['remain_batch'].' 条可推送!'.$artlist;

}

}

return "没有数据被推送!";

}

}

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

【普通文章】模型的是

/dede/article_add.php

【图片集】模型的是

/dede/album_add.php

【软件】模型的是

/dede/soft_add.php

【商品/自定义模型】模型的是

/dede/archives_add.php

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

//返回成功信息

在它上面加入

if(!empty($cfg_xiong_push))

{

$backurl .= "

       ".xiong_push($arcID)."

";

}

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

line-height:36px;height:36px

改成

line-height:36px;

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值