欢迎!我白天是个邮递员,晚上就是个有抱负的演员。这是我的网站。我住在天朝的帝都,有条叫做Jack的狗。
今天我的站长站教大家学会DedeCMS实现百度熊掌号API提交接口推送(PHP推送)。

本教程教大家通过新增内容接口,提交站内 当天新产生 内容的链接。新增内容享受24小时内抓取校验、快速展现优待。
API数据提交代码如下(php代码)
<?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);$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.="http://www.wdzzz.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=realtime'; // 前边的熊掌号ID和密钥换成自己的$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;?>
以上的代码只需要改两个地方,
把http://www.wdzzz.com 改成你自己绑定熊掌号的网址:$urls.="http://www.wdzzz.com"
2、把API接口改成你自己熊掌号新增内容接口:$api = 'http://data.zz.baidu.com/urls?appid=熊掌号ID&token=密钥&type=realtime';
不想手动的朋友可以下载写好的代码。
