欢迎来到万象站长学堂!

DedeCMS

当前位置: 主页 > CMS教程 > DedeCMS > 文章列表

织梦cms熊掌号历史数据提交教程

时间:2026-11-16 15:21:58|栏目:DedeCMS|点击:1 次

前两天公布了织梦熊掌号新增数据API提交工具,很多人来问我历史数据怎么提交,今天就把代码也放出来,供大家交流学习。

本教程是采用php来提交,这样可以全自动的批量提交网站的url。

首先我们看看熊掌号官方给出的示例代码:

$urls = array(
'http://www.example.com/1.html';,
'http://www.example.com/2.html';,
);
$api = 'http://data.zz.baidu.com/urls?appid=1596002713017672&;token=vsaJJ3BFNUGx9lGH&type=batch';
$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;

我们只需要把其中的url地址改为变量,还有就是把API接口改成自己的就行。

冬镜结合织梦的变量修改后的代码如下:

<?php
require_once ("include/common.inc.php");
require_once "include/arc.partview.class.php";
require_once('include/charset.func.php');
$year = date("Y");
$month = date("m");
$day = date("d");
$dayBegin = mktime(0,0,0,7,1,2015);
$dayEnd = mktime(23,59,59,$month,$day,$year);
$query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin."";
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
$urls.="http://dede58.com";.str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls?appid=熊掌号ID&token=密钥&type=batch';
$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;
?>

以上代码大家需要修改三个地方:

1、建站时间

$dayBegin = mktime(0,0,0,7,1,2015);

将上面的时间改成自己的,其中7代表月份,1代表日期,2015代表年份

2、url地址修改

$urls.="http://www.wdzzz.com";.str_replace

将上面的http://www.wdzzz.com修改为你自己的主网站

3、历史数据API接口

$api = 'http://data.zz.baidu.com/urls?appid=熊掌号ID&token=密钥&type=batch';

按照上面的文字说明修改成自己的

好了今天的教程就到这里

上一篇:去除织梦img中的style width height属性方法

栏    目:DedeCMS

下一篇:织梦CMS网站被入侵该如何解决?

本文标题:织梦cms熊掌号历史数据提交教程

本文地址:https://zhanzhang.eapis.site/html/23659.html

您可能感兴趣的文章

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:120507403 | 邮箱:120507403@qq.com

Copyright © 2002-2026 万象站长学堂 版权所有沪ICP备2021023961号-8 粤公网安备 13010202004186