圆柱模板行业B2B站点打造MIP推送+熊掌号推送+历史普通推送插件
最近因为做聚合页面http://www.kaotop.com/ 内部站点关键词拥有5万的行业词库,所以这么多搜索词库,如何让百度第一时间抓取呢?于是就花了10分钟时间写了这个插件,这个插件实现MIP+熊掌号历史推送+普通主动推送三项合一多功能推送,这个是初始版本,也是核心版本,需要其他推送功能可以在此基础上开发。
附上代码:
<?php /* 百度主动推送三项合一功能 作者:68喜科技 用于:DT6.0 功能模块:tags标签推送熊掌号+MIP+普通主动推送 */ //引入错误显示 error_reporting(E_ERROR | E_WARNING | E_PARSE); require '../common.inc.php'; //引入公用函数 $starid =1700; //初始ID 开 $limitList=1000; //限制条数 //资讯标签推送 $query = "SELECT letter FROM {$DT_PRE}keyword WHERE itemid> $starid AND MODULEID=21 ORDER BY itemid ASC LIMIT $limitList"; //查询数据库限制 //产品展示推送 //$query = "SELECT letter FROM {$DT_PRE}keyword WHERE itemid> $starid AND MODULEID=5 ORDER BY itemid ASC LIMIT $limitList"; //查询数据库限制 //图库展示推送 //$query = "SELECT letter FROM {$DT_PRE}keyword WHERE itemid> $starid AND MODULEID=12 ORDER BY itemid ASC LIMIT $limitList"; //查询数据库限制 //推送核心代码 $result = $db->query($query); $urls=""; $domain="http://www.kaotop.com/";//域名 while ($r=$db->fetch_array(($result))) { $linkId = $r['letter']; //获取文章ID $linkurl ="news/search-htm-kw-".$linkId.".html";//定义模块URL //修改域名 $urls.=$domain.$linkurl.","; //echo "为您推送的URL为:<br/>".$urls."<br/>"; } $urls=substr($urls,0,-1); $urls = explode(",",$urls); //接口推送 $api = 'MIP推送接口'; $bdxzhapi='熊掌号历史推送接口';//熊掌号历史推送 $pttsapi='普通主动推送接口';//普通推送 $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 "百度MIP 推送成功:". $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何处藏。 纵使上线又怎样,朝令改,夕断肠。