第一步:
根據熊掌號要求完成校驗頁面,官方文檔很詳細,照着弄就行了
第二步:
開始后台改造
1.進入后台文件夾dede(自己實際的文件夾),然后進入templets目錄,打開body_index.htm
大概104行左右,加入入口鏈接(content_listxzh.php):<div class="icoitem" style="background:url(images/manage1.gif) 10px 3px no-repeat;"><a href="content_listxzh.php">熊掌號管理</a></div>
具體樣子:
-
<div id='quickmenu'>
-
-
$dtp = new DedeTagparse();
-
$dtp->SetNameSpace( 'menu','<','>');
-
$dtp->LoadTemplet($myIcoFile);
-
if(is_array($dtp->CTags)){
-
foreach($dtp->CTags as $ctag){
-
$title = $ctag->GetAtt( 'title');
-
$ico = $ctag->GetAtt( 'ico');
-
$link = $ctag->GetAtt( 'link');
-
echo "<div class='icoitem' style='background:url($ico) 10px 3px no-repeat;'><a href='{$link}'>{$title}</a></div>\r\n";
-
}
-
}
-
-
-
<div class="icoitem" style="background:url(images/manage1.gif) 10px 3px no-repeat;"><a href="content_listxzh.php">熊掌號管理</a></div>
-
</div>
然后刷新后台看看
2.返回上一級目錄,dede下面,復制一份content_list.php,改為content_listxzh.php(和入口鏈接一致),
然后打開該文件,在232行左右,修改模板指向文件,content_list.htm改為content_listxzh.htm
-
//模板
-
if(empty($s_tmplets)) $s_tmplets = 'templets/content_listxzh.htm';
-
$dlist->SetTemplate(DEDEADMIN. '/'.$s_tmplets);
3.再次進入templets文件夾,復制content_list.htm,改為content_listxzh.htm,編輯文件,103行左右加入代碼:
<a href="javascript:xzh(0)" class="coolbg"> 百度熊賬號更新 </a>
保存,然后進入后台查看是否顯示出來
4.進入dede目錄下,js文件夾里面,打開list.js,在最后或者中間加入代碼:
-
function xzh(aid){
-
var qstr=getCheckboxItem();
-
if(aid==0) aid = getOneItem();
-
location= "archives_do.php?qstr="+qstr+"&aid="+aid+"&dopost=xzh";
-
}
在87行左右;插入代碼:
new ContextItem("熊賬號更新",function(){ xzh(aid); }),
new ContextItem("熊賬號更新",function(){ xzh(aid); }),
5.進入dede目錄下,打開archives_do.php 在267行左右加入推送代碼:
-
/*--------------------------
-
//熊掌號更新
-
function xzh() { }
-
---------------------------*/
-
else if($dopost=="xzh")
-
{
-
CheckPurview( 'a_Check,a_AccCheck,sys_ArcBatch');
-
require_once(DEDEADMIN."/inc/inc_archives_functions.php");
-
if( !empty($aid) && empty($qstr) ) $qstr = $aid;
-
if($qstr=='')
-
{
-
ShowMsg( "參數無效!",$ENV_GOBACK_URL);
-
exit();
-
}
-
$arcids = preg_replace( "#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
-
$query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
-
t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath,t.isdefault,t.defaultname
-
from `#@__archives` arc left join #@__arctype t on arc.typeid=t.id
-
WHERE arc.id in($arcids) ";
-
$dsql->SetQuery($query);
-
$dsql->Execute();
-
-
$data= array();
-
while($row = $dsql->GetArray())
-
{
-
-
$preRow=$row;
-
$data[]=GetFileUrl($preRow[ 'id'],$preRow['typeid'],'',$preRow['title'],
-
$preRow[ 'ismake'],0,$preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],
-
$preRow[ 'moresite'],$preRow['siteurl'],$preRow['sitepath']);
-
-
}
-
-
$urls=$data;
-
$api = 'http://data.zz.baidu.com/urls?appid=你的熊掌號id&token=bGtk3lFYrn6XQJBY&type=batch';
-
$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;
-
-
ShowMsg($result,$ENV_GOBACK_URL);
-
exit();
-
}
注意填寫自己的熊掌號id
最后測試一下結果:顯示成功success
,以上就是所有過程,我自己寫的api接口,其他接口也可以按照這個思路來寫,,你也可以按照這個自己定義一個原創內容推送接口,主要是接口地址正確,對應的自定義文件鏈接正確,一般都沒多大問題,未經允許,請勿私自轉載