destoon7.0百度熊掌号主动推送插件

2019-01-10 873浏览
 在根目录新建一个xz_news.php文件,运行即可。(代码以资讯模块为例,其他模块请自行参照后台修改 数据表代码 article_21)

二话不说,直接上代码

<?php

//引入全局变量函数

require '../common.inc.php';

$time = time();

$starttime = $time - 24*3600;//24小时

$query = "SELECt linkurl FROM {$DT_PRE}article_21 WHERe edittime > $starttime ORDER BY itemid ASC";

$result = $db->query($query);

$urls="";

$domain="https://www.17jiaoliu.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;

?>