百度熊掌号当天推送工具。大家都知道,熊掌号对网站的关联度和流量都是有好处的,今天我分享的这个插件应用前提是:本事自己网站是做过熊掌号适配的,否则提交不成功哦。
首先第一步:在api/cron目录下新建一个xz_news.inc.php
代码:
- <?php
- //引入全局变量函数
- defined('IN_DESTOON') or exit('Access Denied');
- $time = $today_endtime - 30*86400;
- $time = time();
- $starttime = $time - 24*3600;//24小时
- $limitList=20; //限制条数
- $query = "SELECt linkurl FROM {$DT_PRE}article_21 WHERe edittime > $starttime AND thumb<>'' ORDER BY itemid ASC LIMIT $limitList"; //查询当天出图的数据URL
- //开始全部推送
- $result = $db->query($query);
- $urls="";
- $domain="https://www.mbkfw.com/mobile/course/";//修改为你自己的手机端链接
- while ($r=$db->fetch_array(($result)))
- {
- $linkurl = $r['linkurl'];
- //修改域名
- $urls.=$domain.$linkurl.",";
- }
- $urls=substr($urls,0,-1);
- $urls = explode(",",$urls);
- //百度熊掌推送
- $api = '熊掌号接口';
- $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;
- ?>
二步,在后台-定时任务 中添加一个任务
任务名称:文章熊掌内容提交
脚本文件:xz_news.inc.php
执行方式:每天执行
如图: