织梦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';
按照上面的文字說明修改成自己的
好了今天的教程就到這里
總結
以上是生活随笔為你收集整理的织梦cms提交熊掌号php,织梦cms熊掌号历史数据提交教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 去除字符前空格,php中删除字符
- 下一篇: 可能是史上最美手机!魅族20系列来了:视