dt7.0百度熊掌當天主動推送方法
阿新 • • 發佈:2018-07-25
text appid lai con 全局變量 bsp tar common str
因自己沒事新做了一個網站,申請了一個熊掌號,所以做了這個主動推送接口,希望能收錄快些,在此分享下關於DT7.0主動當天推送功能
上代碼:
<?php /* 百度當天主動推送熊掌功能 作者:68喜科技 用於:DT7.0 */ //引入全局變量函數 require ‘../common.inc.php‘; $time = time(); $starttime = $time - 24*3600;//24小時 $query = "SELECt linkurl FROM {$DT_PRE}article_23 WHERe edittime > $starttime ORDER BY itemid ASC"; $result = $db->query($query); $urls=""; $domain="http://baijia.xuetong365.com/";//修改您的網站域名 while ($r=$db->fetch_array(($result))) { $linkurl = $r[‘linkurl‘]; //修改域名 $urls.=$domain.$linkurl.","; } $urls=substr($urls,0,-1); $urls = explode(",",$urls); //百度熊掌推送 $api = ‘http://data.zz.baidu.com/urls?appid=你的熊掌ID&token=您的熊掌toke秘鑰&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; ?>
dt7.0百度熊掌當天主動推送方法