织梦园模板网专注于织梦企业模板、DeDe整站模板、织梦Html5模板等织梦模板的下载,提供DEDE织梦模板相关服务。织梦园织梦模板交流群
用户名:
密码:
注册
注册后享受折扣价

熊掌号自动API如何绑定织梦dedecms提交当日资源

织梦园模板 / 2019-03-21 / 收藏

        随着熊掌号对手机排名影响的日益明显,很多站长重视熊掌号作用,有很多站长朋友来咨询织梦园,织梦有没有插件或者代码能自动提交熊掌号数据的,期间我也帮助了不少站长,发现还是直接发一个教程,以后大家直接看教程操作。 在这里教大家学会DedeCMS实现百度熊掌号API提交接口推送(PHP推送)。


        百度熊掌号API自动提交织梦数据

 

       本教程教大家通过新增内容接口,提交站内 当天新产生 内容的链接。新增内容享受24小时内抓取校验、快速展现优待。 API数据提交代码如下(PHP代码)


<?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.="http://dedeyuan.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;
?>
以上的代码只需要改两个地方,如下图红圈所示:
织梦熊掌号修改教程


1、把下方的http://dedeyuan.com 改成你自己绑定熊掌号的网址

    $urls.="
http://dedeyuan.com"

2、把API接口改成你自己熊掌号新增内容接口

 $api = 'http://data.zz.baidu.com/urls?appid=熊掌号ID&token=密钥&type=realtime';

      教程到此结束希望给能给大家带来帮助!

相关织梦教程

收缩