国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 織夢(mèng)DEDE > 正文

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

2024-07-12 09:08:18
字體:
供稿:網(wǎng)友

熊掌號(hào)的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)容會(huì)進(jìn)入百度搜索統(tǒng)一處理流程,這個(gè)過程需要一段時(shí)間。

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

$urls = array(        'http://www.CUOxin.com/1.html',        'http://www.CUOxin.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熊掌號(hào)API提交之新增內(nèi)容接口代碼:

<?phprequire_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.CUOxin.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";//將上邊m.CUOxin.com換成你的網(wǎng)址}$urls=substr($urls,0,-1);$urls = explode(",",$urls);$api = 'http://data.zz.baidu.com/urls?appid=熊掌號(hào)ID&token=密鑰&type=realtime'; // 前邊的熊掌號(hào)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.CUOxin.com/1.html',        'http://www.CUOxin.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熊掌號(hào)API提交之歷史內(nèi)容接口代碼:

<?phprequire_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.CUOxin.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";//將上邊的https://m.CUOxin.com換成你的網(wǎng)址}$urls=substr($urls,0,-1);$urls = explode(",",$urls);$api = 'http://data.zz.baidu.com/urls?appid=XXXXXXXXXX&token=xxxxxxxxxxxxx&type=batch';// 前邊的熊掌號(hào)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)獲取當(dāng)天發(fā)布的所有文章鏈接,設(shè)置兩個(gè)時(shí)間戳,0:0:0和23:59:59,也就是把當(dāng)天這兩個(gè)時(shí)間內(nèi)的文章都自動(dòng)提取出來,即是當(dāng)天新增內(nèi)容內(nèi)容。

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


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

織夢(mèng)實(shí)現(xiàn)百度熊掌號(hào)API提交接口主動(dòng)推送下載
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 名山县| 普格县| 肥东县| 合江县| 汶川县| 延庆县| 上犹县| 油尖旺区| 郴州市| 三都| 玉环县| 宝丰县| 泸西县| 江达县| 车险| 安顺市| 建水县| 桃江县| 德兴市| 商南县| 贵南县| 上林县| 上林县| 屯留县| 石柱| 小金县| 辽阳县| 萨嘎县| 宜君县| 宣化县| 建宁县| 西充县| 石泉县| 河东区| 荃湾区| 紫阳县| 德惠市| 中山市| 安吉县| 格尔木市| 颍上县|