discuz discuz发贴后自动提交到百度 api推送代码

busycy

Administrator
管理成员
找到文件路径:
代码:
/source/include/post/post_newthread.php

查找309行:

代码:
showmessage($return, $returnurl, array_merge($values, (array)$modthread->param('values')), $modthread->param('param'));

在前面添加:

代码:
xb1_submit(array($tid));

文件最后(?>前)添加:

代码:
function xb1_submit($tids){

    foreach ($tids as $key=>$value){

        $urls[] = 'https://www.xb1.com/bbs/threads-'.$value.'-1-1.html';

       //这里提交了伪静态规则的贴,改为你自己的规则,如果你的是动态的,改为$urls[] = 'http://你的域名/forum.php?mod=viewthread&tid='.$value;

    }

    $api = 'http://data.zz.baidu.com/urls?site=你的网址&token=你的token值';

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

    return $result;

}
 
顶部