蘇州高端網站設計
Our toughts in one place
織夢對接熊掌號站點周級收錄接口
發布者:龍媒SEO 來源: 時間:2019-09-20 查看:1136次通過對接周級收錄接口,每天可提交最多500萬條有價值的內容,本文分享織夢系統網站如何對接熊掌號站點周級收錄,實現自動API提交。
申請熊掌號的具體操作就不細說了,熊掌號綁定織夢網站后,百度后臺會給出如圖所示的推送接口
第一步:
打開織夢后臺,依次點擊 系統 - 系統基本參數 - 添加新變量 如圖所示
變量名稱:cfg_xiong_push
變量值:百度熊掌號中給出的調用接口地址;如:http://data.zz.baidu.com/urls?appid=164380*****33&token=6H7j*****HPYz&type=batch
參數說明:熊掌號API
第二步:
打開織夢網站跟目錄,找到 /dede/inc/inc_archives_functions.php 在最后添加如下代碼:
打開織夢網站跟目錄,找到 /dede/inc/inc_archives_functions.php 在最后添加如下代碼:
/** * 熊掌主動推送 */function xiong_push($id="",$qstr=""){ global $cfg_multi_site,$cfg_basehost,$cfg_xiong_push; if(!empty($id) && !empty($cfg_xiong_push)) { if( !empty($id) && empty($qstr) ) $qstr = $id; if($qstr=='') { exit(); } $qstrs = explode('`',$qstr); $cfg_domain = $cfg_multi_site == 'N' ? $cfg_basehost : ''; $urls = array(); $i = 0; foreach($qstrs as $aid) { $i++; $arcrow = GetOneArchive($aid); $url = $cfg_domain.$arcrow['arcurl']; $urls[] = $url; $artlist .= $url." "; } if($i>1) $artlist = ""; if(!empty($urls)){ $ch = curl_init(); $options = array( CURLOPT_URL => trim($cfg_xiong_push), 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); curl_close($ch); $result = json_decode($result, true); if(isset($result['error'])){ return '熊掌主動推送失敗,錯誤碼:'.$result['error'].' message:'.$result['message']; }else{ $not_same_site = isset($result['not_same_site'][0]) ? " 推送鏈接與熊掌綁定站點不一致 " : ""; $not_valid = isset($result['not_valid'][0]) ? " 推送鏈接不合法 " : ""; return $not_same_site . $not_valid . '熊掌主動推送成功 '.$result['success_batch'].' 條!當天剩余 '.$result['remain_batch'].' 條可推送!'.$artlist; } } return "沒有數據被推送!"; }}
第三步:
打開 /dede/article_add.php 搜索文件中的
//返回成功信息
在前面加入如下代碼:
if(!empty($cfg_xiong_push)) { $backurl .= " ".xiong_push($arcID)."
"; }
繼續搜索:
line-height:36px;height:36px
改為:
line-height:36px;
確保樣式正確。
這樣就大功告成了,我們可以發布新文檔試試看有沒有成功的返回值。
標簽: