东方星雨

简单网络

一个爱好网络的80后男站长。

关注我东方星雨个人微信号:476847113

您现在的位置是:首页 > 站长日志

帝国CMS二次开发百度主动推送功能教程

2015-05-29 站长 站长日志

补充一点服务器要支持CURL权限

方法一:发布一个文章推送一个文章
修改文件:eclasshinfofun.php
大概在316行

//同时发布
        $copyclassid=$add[copyclassid];
        $cpcount=count($copyclassid);
        if($cpcount)
        {
                $copyids=AddInfoToCopyInfo($add[classid],$id,$copyclassid,$userid,$username,$doselfinfo);
                if($copyids)
                {
                        UpdateInfoCopyids($add['classid'],$id,$copyids);
                }
        }
        $urls=$infourl;//系统后台填写如 http://www.baidu.com/这样的格式用这个句
        //$urls='http://www.baidu.com'.$infourl;//你的系统后台默认填写的/,这里需要你填写你的与名
        $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;        
        if($sql)
        {
                //返回地址


方法2:一次推送每天发布的新文章链接
在根目录下新建立一个文件
代码如下

<?php
require(dirname(__FILE__).'/e/class/connect.php');
require(dirname(__FILE__).'/e/class/q_functions.php');
require(dirname(__FILE__).'/e/class/db_sql.php');
require(dirname(__FILE__).'/e/data/dbcache/class.php');
$link=db_connect();
$empire=new mysqlquery();
$pageurl=$public_r['newsurl'];
$tbname='';
//默认表
if(empty($tbname))
{
        $tbname=$public_r['tbname'];
        $mid=$etable_r[$tbname][mid];
        $yhid=$etable_r[$tbname][yhid];
}
if(empty($tbname)||InfoIsInTable($tbname))
{
        printerror('ErrorUrl','',1);
}
//替换
function RepSpeRssStr($str){
        $str=stripSlashes($str);
        $str=ehtmlspecialchars($str,ENT_QUOTES);
        $str=str_replace(array('
        

文章评论