sokucc 发表于 2017-12-21 23:48:07

destoon6.0免费插件-主动推送24小时内最新链接列表至百度


设置定时任务,
/php根目录/php/bin/php /网站根目录/api/cron/baidu.php
baidu.php文件内容,
//主动推送24小时内最新链接列表至百度
//执行: /php根目录/php/bin/php /网站根目录/api/cron/baidu.php
<?php
require '../../common.inc.php';

$time = time();

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

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

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

$urls="";

while ($r=$db->fetch_array(($result)))

{

$linkurl = $r['linkurl'];

//修改域名

$urls.="http://域名/sell/".$linkurl.",";

}

$urls=substr($urls,0,-1);

$urls = explode(",",$urls);

//修改下一行

$api = 'http://data.zz.baidu.com/urls?site=域名&token=XXXXXXXXXXXXXXXX';

$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;

?>

页: [1]
查看完整版本: destoon6.0免费插件-主动推送24小时内最新链接列表至百度