DT7.0搜索关键词记录推送熊掌号+普通主动推送
为了seo需要,把大量的搜索关键词记录推送熊掌号达到更快的收录。而且网上没有人分享这方便,所以抽空自己写了一个,因为我自己搜索伪静态开启了拼音伪静态,如果你们默认是官方的中文伪静态就把我拼音的伪静态控制关闭即可!
<?php /* 百度主动推送三项合一功能 作者:68喜 功能模块:搜索关键词记录推送熊掌号当天推送+熊掌号历史推送+普通主动推送 */ //错误显示屏蔽 error_reporting(E_ERROR | E_WARNING | E_PARSE); require './common.inc.php'; //引入公用函数 $starid = 1; //初始ID 开 $limitList=2000; //限制条数,因为熊掌号一次只能推送2000 $module=5;//模块推送,21资讯,5供应,22招商,13品牌,9招聘,10知道,12图片,14视频,15下载,18论坛 $query = "SELECT letter FROM {$DT_PRE}keyword WHERE itemid> $starid AND MODULEID=$module ORDER BY itemid ASC LIMIT $limitList"; //拼音 //$query = "SELECT word FROM {$DT_PRE}keyword WHERE itemid> $starid AND MODULEID=$module ORDER BY itemid ASC LIMIT $limitList";//中文 //推送核心代码 $result = $db->query($query); $urls=""; $domain=$CFG['url'];//这个是获取配置文件的域名,格式是:http://www.sdfymj.com/ if($module==21){ $dir='news/'; }elseif($module==5){ $dir='sell/'; }elseif($module==22){ $dir='invest/'; }elseif($module==15){ $dir='down/'; }elseif($module==18){ $dir='club/'; }//如果目录重新改过可以在这添加和修改 while ($r=$db->fetch_array(($result))) { $linkId = $r['letter']; //获取拼音 //$linkId = $r['word']; //如果是中文url就开启这个 $linkurl = $dir."kw-".$linkId.".html";//定义模块URL $urls.=$domain.$linkurl.","; //echo "为您推送的URL为:<br/>".$urls."<br/>"; } $urls=substr($urls,0,-1); $urls = explode(",",$urls); //接口推送 $api = 'http://data.zz.baidu.com/urls?appid=1653777056766918&token=&type=realtime';//熊掌号当天推送 $bdxzhapi='http://data.zz.baidu.com/urls?appid=1653777056766918&token=NXneuRZh3lNV5YpH&type=batch';//熊掌号历史推送 $pttsapi='http://data.zz.baidu.com/urls?site=www.sdfymj.com&token=Cuf4OAyyzP3Kp7bz';//普通推送 $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."<br/>"; $options = array( CURLOPT_URL => $bdxzhapi, 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."<br/>"; $options = array( CURLOPT_URL => $pttsapi, 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."<br/>"; ?>
千行代码,Bug何处藏。 纵使上线又怎样,朝令改,夕断肠。