1. 程式人生 > >dede織夢系統接入熊掌號推送api,完整詳細教程

dede織夢系統接入熊掌號推送api,完整詳細教程

default ppi 模板 alt for fcm body ext plain

第一步:
根據熊掌號要求完成校驗頁面,官方文檔很詳細,照著弄就行了
第二步:
開始後臺改造

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>

具體樣子:

  1. <div id=‘quickmenu‘>
  2. <?php
  3. $dtp = new DedeTagparse();
  4. $dtp->SetNameSpace(‘menu‘,‘<‘,‘>‘);
  5. $dtp->LoadTemplet($myIcoFile);
  6. if(is_array($dtp->CTags)){
  7. foreach($dtp->CTags as $ctag){
  8. $title = $ctag->GetAtt(‘title‘);
  9. $ico = $ctag->GetAtt(‘ico‘);
  10. $link = $ctag->GetAtt(‘link‘);
  11. echo "<div class=‘icoitem‘ style=‘background:url($ico) 10px 3px no-repeat;‘><a href=‘{$link}‘>{$title}</a></div>\r\n";
  12. }
  13. }
  14. ?>
  15. <div class="icoitem" style="background:url(images/manage1.gif) 10px 3px no-repeat;"><a href="content_listxzh.php">熊掌號管理</a></div>
  16. </div>

技術分享圖片

然後刷新後臺看看

技術分享圖片

2.返回上一級目錄,dede下面,復制一份content_list.php,改為content_listxzh.php(和入口鏈接一致),

然後打開該文件,在232行左右,修改模板指向文件,content_list.htm改為content_listxzh.htm

  1. //模板
  2. if(empty($s_tmplets)) $s_tmplets = ‘templets/content_listxzh.htm‘;
  3. $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,在最後或者中間加入代碼:

  1. function xzh(aid){
  2. var qstr=getCheckboxItem();
  3. if(aid==0) aid = getOneItem();
  4. location="archives_do.php?qstr="+qstr+"&aid="+aid+"&dopost=xzh";
  5. }


在87行左右;插入代碼:

new ContextItem("熊賬號更新",function(){ xzh(aid); }),
    new ContextItem("熊賬號更新",function(){ xzh(aid); }),

技術分享圖片

5.進入dede目錄下,打開archives_do.php 在267行左右加入推送代碼:

  1. /*--------------------------
  2. //熊掌號更新
  3. function xzh() { }
  4. ---------------------------*/
  5. else if($dopost=="xzh")
  6. {
  7. CheckPurview(‘a_Check,a_AccCheck,sys_ArcBatch‘);
  8. require_once(DEDEADMIN."/inc/inc_archives_functions.php");
  9. if( !empty($aid) && empty($qstr) ) $qstr = $aid;
  10. if($qstr==‘‘)
  11. {
  12. ShowMsg("參數無效!",$ENV_GOBACK_URL);
  13. exit();
  14. }
  15. $arcids = preg_replace("#[^0-9,]#", ‘‘, preg_replace("#`#", ‘,‘, $qstr));
  16. $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
  17. t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath,t.isdefault,t.defaultname
  18. from `#@__archives` arc left join #@__arctype t on arc.typeid=t.id
  19. WHERE arc.id in($arcids) ";
  20. $dsql->SetQuery($query);
  21. $dsql->Execute();
  22. $data=array();
  23. while($row = $dsql->GetArray())
  24. {
  25. $preRow=$row;
  26. $data[]=GetFileUrl($preRow[‘id‘],$preRow[‘typeid‘],‘‘,$preRow[‘title‘],
  27. $preRow[‘ismake‘],0,$preRow[‘namerule‘],$preRow[‘typedir‘],$preRow[‘money‘],$preRow[‘filename‘],
  28. $preRow[‘moresite‘],$preRow[‘siteurl‘],$preRow[‘sitepath‘]);
  29. }
  30. $urls=$data;
  31. $api = ‘http://data.zz.baidu.com/urls?appid=你的熊掌號id&token=bGtk3lFYrn6XQJBY&type=batch‘;
  32. $ch = curl_init();
  33. $options = array(
  34. CURLOPT_URL => $api,
  35. CURLOPT_POST => true,
  36. CURLOPT_RETURNTRANSFER => true,
  37. CURLOPT_POSTFIELDS => implode("\n", $urls),
  38. CURLOPT_HTTPHEADER => array(‘Content-Type: text/plain‘),
  39. );
  40. curl_setopt_array($ch, $options);
  41. $result = curl_exec($ch);
  42. echo $result;
  43. ShowMsg($result,$ENV_GOBACK_URL);
  44. exit();
  45. }

註意填寫自己的熊掌號id

技術分享圖片

最後測試一下結果:顯示成功success

技術分享圖片

技術分享圖片

,以上就是所有過程,我自己寫的api接口,其他接口也可以按照這個思路來寫,,你也可以按照這個自己定義一個原創內容推送接口,主要是接口地址正確,對應的自定義文件鏈接正確,一般都沒多大問題,未經允許,請勿私自轉載

dede織夢系統接入熊掌號推送api,完整詳細教程