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

前两天公布了织梦熊掌号新增数据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接口改成自己的就行。

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".$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、建站时间以上代码大家需要修改三个地方:

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

2、url地址修改

$urls.="http://www.11px.cn".str_replace

3、历史数据API接口将上面的http://www.11px.cn修改为你自己的主网站

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

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

好了今天的教程就到这里

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值