网站首页 | 仿站联系QQ:305114474
游客,欢迎您! 请登录 免费注册 忘记密码
您所在的位置:首页 > 站内新闻 > 正文

dedecms(织梦网站)如何设置百度主动推送api以及移动pc同时推送教程

发布日期:2020/12/19 10:38:02 浏览次数:69 加入收藏 评论:0 标签:dedecms 织梦

 dedecms(织梦网站)应该如何设置百度主动推送api以及移动pc同时推送呢?设置百度主动推送api以及移动pc同时推送教程:

网站如何在添加文章后主动向百度推送api
1、根目录下dede后台目录里article_add.php中257行
2、在以下代码后,另起一行

if($artUrl=='')
{
$artUrl = $cfg_phpurl."/view.php?aid=$arcID";
}
新增以下代码

else{
$urls[]='根据实际情况保留http或者https://'.$_SERVER['HTTP_HOST'].$artUrl;
$api = 'http://data.zz.baidu.com/urls?site=你的域名&token=你的token代码';
$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);
}
3、在下方$backurl的上方增加代码,方便查看推送结果

<u>主动推送反馈结果".$result."</u>

如何同时提交pc和移动端?
1、将以上内容改造一下 ,代码已用颜色区分开。

//start
if($artUrl=='')
{
$artUrl = $cfg_phpurl."/$arcID.html";//pc端提交
$artUrl1 = $cfg_phpurl."/view.php?aid=$arcID";//移动端提交
}
else{
//pc端
$urls[]='https://'.$_SERVER['HTTP_HOST'].$artUrl;
$api = 'http://data.zz.baidu.com/urls?site=https://你的pc域名&token=你的token代码';
$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);
}
ClearMyAddon($arcID, $title);
//移动端
$urls1[]='https://你的移动域名'.$artUrl1;
$api1 = 'http://data.zz.baidu.com/urls?site=https://你的移动域名&token=你的token代码';
$ch1 = curl_init();
$options1 = array(
CURLOPT_URL => $api1,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode("\n", $urls1),
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch1, $options1);
$result1 = curl_exec($ch1);
//end
2、在下方$backurl的上方增加代码,方便查看推送结果

<u>pc端主动推送反馈结果".$result."</u>
&nbsp;&nbsp;
<u>移动端主动推送反馈结果".$result1."</u>
&nbsp;&nbsp;


备注:部分网站模板整理自网络,如有侵权,请及时与我们沟通处理。
如若看不到文章内容及下载地址,注册免费会员既可。
更多好看的企业SDCMS模板可加QQ群:SDCMS企业模板分享 (群号:147412231) 企业模板SDCMS分享。
本文网址:http://www.hbsenbao.com/html/news/214.html
读完这篇文章后,您心情如何?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
更多>>网友评论
发表评论