欢迎来到258分享网,纯净的网络源码分享基地!

258资源分享网

全部作品
全部作品
网站源码
微信源码
素材特效
源码插件
视频教程
建站学院
热门搜索: 织梦  农业种植  农业  安全设置  官方
258资源分享 > 建站学院 > 织梦教程 > DEDECMS织梦程序实现熊掌号API提交接口推送(PHP推送)

推荐下载

HTML5响应式自适应网咯设计

2020-05-12   浏览:738

高端HTML5响应式企业通用网

2020-05-06   浏览:521

html5响应式外贸网站英文版

2020-05-08   浏览:510

HTML5自适应律师工作室类网

2020-04-04   浏览:502

HTML5影视传媒文化公司类网

2020-05-12   浏览:497

DEDECMS织梦程序实现熊掌号API提交接口推送(PHP推送)

发布时间:2020-02-27  

熊掌号的API提交分为新增内容接口和历史内容接口两个接口。通过新增内容接口,提交站内 当天新产生内容的链接。新增内容享受24小时内抓取校验、快速展现优待。仅限提交绑定站点下的内容,否则无法成功提交,配额不可累计,当日有效。而通过历史内容接口,每天可提交最多500万条有价值的内容,所提交内容会进入百度搜索统一处理流程,这个过程需要一段时间。

一、PHP推送新增内容接口代码为:
 

$urls = array( '', '', ); $api = '?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提交之新增内容接口代码:

<?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);//当天开始时间戳 $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.""; //echo $query; $urls=""; $dsql->Execute('arch.id,types.typedir',$query); while($row = $dsql->GetArray('arch.id,types.typedir')) { $urls.="https://m.dede58.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; //将上边m.dede58.com换成你的网址 } $urls=substr($urls,0,-1); $urls = explode(",",$urls); $api = '?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推送历史内容接口代码为

$urls = array( '', '', ); $api = '?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提交之历史内容接口代码:

<?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.""; //echo $query; $urls=""; $dsql->Execute('arch.id,types.typedir',$query); while($row = $dsql->GetArray('arch.id,types.typedir')) { $urls.="https://m.dede58.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; //将上边的https://m.dede58.com换成你的网址 } $urls=substr($urls,0,-1); $urls = explode(",",$urls); $api = '?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”为自己数据库中存放文章的表,如果你的数据库表头做了修改,这里也要做相应修改。