麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > CMS > 織夢DEDE > 正文

DEDECMS織夢程序?qū)崿F(xiàn)熊掌號API提交接口推送(PHP推送)

2024-08-30 19:08:10
字體:
供稿:網(wǎng)友

熊掌號的API提交分為新增內(nèi)容接口歷史內(nèi)容接口兩個(gè)接口。通過新增內(nèi)容接口,提交站內(nèi) 當(dāng)天新產(chǎn)生內(nèi)容的鏈接。新增內(nèi)容享受24小時(shí)內(nèi)抓取校驗(yàn)、快速展現(xiàn)優(yōu)待。僅限提交綁定站點(diǎn)下的內(nèi)容,否則無法成功提交,配額不可累計(jì),當(dāng)日有效。而通過歷史內(nèi)容接口,每天可提交最多500萬條有價(jià)值的內(nèi)容,所提交內(nèi)容會進(jìn)入百度搜索統(tǒng)一處理流程,這個(gè)過程需要一段時(shí)間。

一、PHP推送新增內(nèi)容接口代碼為:
 

$urls = array(

        'http://www.xiuzhanwang.com/1.html',

        'http://www.xiuzhanwang.com/2.html',

);

$api = 'http://data.zz.baidu.com/urls?appid=XXXXXXXXX&token=xxxxxxxxxxxxx&type=realtime';

$ch = curl_init();

$options = array(

        CURLOPT_URL => $api,

        CURLOPT_POST => true,

        CURLOPT_RETURNTRANSFER => true,

        CURLOPT_POSTFIELDS => implode(" ", $urls),

        CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),

);

curl_setopt_array($ch, $options);

$result = curl_exec($ch);

echo $result;


DedeCMS熊掌號API提交之新增內(nèi)容接口代碼:

<?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,$month,$day,$year);//當(dāng)天開始時(shí)間戳

$dayEnd = mktime(23,59,59,$month,$day,$year);//當(dāng)天結(jié)束時(shí)間戳 

 

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

//echo $query;

 

$urls="";

 

$dsql->Execute('arch.id,types.typedir',$query);

while($row = $dsql->GetArray('arch.id,types.typedir'))

{

$urls.="https://m.xiuzhanwang.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";

//將上邊m.xiuzhanwang.com換成你的網(wǎng)址

}

$urls=substr($urls,0,-1);

$urls = explode(",",$urls);

 

$api = 'http://data.zz.baidu.com/urls?appid=熊掌號ID&token=密鑰&type=realtime'; // 前邊的熊掌號ID和密鑰換成自己的

$ch = curl_init();

$options =  array(

    CURLOPT_URL => $api,

    CURLOPT_POST => true,

    CURLOPT_RETURNTRANSFER => true,

    CURLOPT_POSTFIELDS => implode(" ", $urls),

    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),

);

curl_setopt_array($ch, $options);

$result = curl_exec($ch);

echo $result;

?>

 


二、PHP推送歷史內(nèi)容接口代碼為

$urls = array(

        'http://www.xiuzhanwang.com/1.html',

        'http://www.xiuzhanwang.com/2.html',

);

$api = 'http://data.zz.baidu.com/urls?appid=XXXXXXXXXX&token=xxxxxxxxxxxxx&type=batch';

$ch = curl_init();

$options = array(

        CURLOPT_URL => $api,

        CURLOPT_POST => true,

        CURLOPT_RETURNTRANSFER => true,

        CURLOPT_POSTFIELDS => implode(" ", $urls),

        CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),

);

curl_setopt_array($ch, $options);

$result = curl_exec($ch);

echo $result;



DedeCMS熊掌號API提交之歷史內(nèi)容接口代碼:

<?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);//網(wǎng)站開始運(yùn)行時(shí)間戳

$dayEnd = mktime(23,59,59,$month,$day,$year);//當(dāng)天結(jié)束時(shí)間戳 

 

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

//echo $query;

 

$urls="";

 

$dsql->Execute('arch.id,types.typedir',$query);

while($row = $dsql->GetArray('arch.id,types.typedir'))

{

$urls.="https://m.xiuzhanwang.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";

//將上邊的https://m.xiuzhanwang.com換成你的網(wǎng)址

}

$urls=substr($urls,0,-1);

$urls = explode(",",$urls);

 

$api = 'http://data.zz.baidu.com/urls?appid=XXXXXXXXXX&token=xxxxxxxxxxxxx&type=batch';// 前邊的熊掌號ID和密鑰換成自己

$ch = curl_init();

$options =  array(

    CURLOPT_URL => $api,

    CURLOPT_POST => true,

    CURLOPT_RETURNTRANSFER => true,

    CURLOPT_POSTFIELDS => implode(" ", $urls),

    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),

);

curl_setopt_array($ch, $options);

$result = curl_exec($ch);

echo $result;

?>


代碼釋義:

1、$query中“dede_archives”為自己數(shù)據(jù)庫中存放文章的表,如果你的數(shù)據(jù)庫表頭做了修改,這里也要做相應(yīng)修改。

2、本代碼自動獲取當(dāng)天發(fā)布的所有文章鏈接,設(shè)置兩個(gè)時(shí)間戳,0:0:0和23:59:59,也就是把當(dāng)天這兩個(gè)時(shí)間內(nèi)的文章都自動提取出來,即是當(dāng)天新增內(nèi)容內(nèi)容。

3、$api=http://data.zz.baidu.com/urls?appid=熊掌號ID&token=密鑰&type=realtime,請登錄您的賬號查看接口調(diào)用地址。


下載文件DedeCMS熊掌號API提交新增內(nèi)容接口文件和DedeCMS熊掌號API提交歷史內(nèi)容接口文件,解壓后,修改文件,將文件中的密鑰和網(wǎng)址改成自己的即可,將修改后的PHP文件上傳到網(wǎng)站根目錄,瀏覽器中輸入:你的域名/baiduxz_new.php和你的域名/baiduxz_old.php,即可看到API提交的效果。

網(wǎng)盤下載:https://pan.baidu.com/s/1unqgztIpc9CoU7D2voNa5w 提取碼: mjuz 


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 成人在线视频在线观看 | 国产精品成人亚洲一区二区 | 久草在线综合 | 午夜视频久久 | 一级片免费在线 | 国产精品久久久久久婷婷天堂 | 日韩视频一区二区三区在线观看 | 91精品国产乱码久久桃 | 国产日韩免费观看 | 久久精品一区二区三区四区五区 | 免费观看国产精品视频 | 欧美无极品 | 国产精品视频六区 | 国产毛片aaa一区二区三区视频 | 日韩av成人| 最新欧美精品一区二区三区 | 欧美一级不卡视频 | 青草久久久久 | 久久久久久久午夜 | 亚洲免费网站 | 意大利av在线 | 国产一区二区精彩视频 | 久久国产午夜 | 亚洲欧美日韩中文在线 | 九草在线视频 | 成人在线不卡 | 久国产| fc2成人免费人成在线观看播放 | 国产精品看片 | 精品黑人一区二区三区国语馆 | 久国产精品视频 | 在线观看福利网站 | 青青草成人影视 | 人成免费网站 | 久久人人97超碰国产公开结果 | 国产精品一区网站 | 欧美成人精品一区 | 国产1区2区3区中文字幕 | 免费观看一区二区三区 | 国产在线色 | 牛牛a级毛片在线播放 |