帝国cms教程

帝国CMS7.5/PHP每日自动推送新增文章到百度api/推送百度快速收录/多表调用推送

帝国cms教程 51源码 2021-12-06 人阅读
帝国CMS的插件每次都需要手动才能推送快速收录!对我这样的懒人,简直是没法接受!所以做了个每日自动推送最新信息的文件!
网上的一些教程都是单独一个表进行推送的,但是我这个是多表查询,共同取最新的信息进行推送!
第一步,我们在网站根目录新建一个PHP文件,如tuisong.php。

<?php
require("e/class/connect.php");
require("e/class/db_sql.php");
require("e/data/dbcache/class.php");
$link=db_connect();
$empire=new mysqlquery();
/********密码验证***********/
$key='www.51yma.cn';    //这个密码是登陆验证用的.您需要在模块里设置和这里一样的密码....注意一定需要修改.
if($key!=$_GET['key']) exit('验证密码错误');   //安全检测,密码不符则退出

    $query = 'select * from (

select id,classid,titleurl,filename,title,newstime,titlepic from phome_ecms_muban where newstime union

select id,classid,titleurl,filename,title,newstime,titlepic from phome_ecms_chajian where newstime union

select id,classid,titleurl,filename,title,newstime,titlepic from phome_ecms_download where newstime union

select id,classid,titleurl,filename,title,newstime,titlepic from phome_ecms_ruanjian where newstime union

select id,classid,titleurl,filename,title,newstime,titlepic from phome_ecms_article where newstime) a order

by newstime desc limit 10';//我这里取的是最新10条信息,因为我推送的是快速收录,目前一天只能推送10条。
    $sql=$empire->query($query);

    while($r=$empire->fetch($sql)){
        $newstime = date('Y-m-d',$r['newstime']);
        $titleurl=sys_ReturnBqTitleLink($r);
        $urls[]= "https://www.51yma.cn".$titleurl;
    }


$api = 'http://data.zz.baidu.com/urls?site=https://www.51yma.cn&token=*********';//普通收录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;

?>

注意这里!

第二部,在宝塔面板的计划任务中新建一个计划任务,执行周期按照每日来设置,具体执行时间自行安排!

这样就OK 了,每日自动执行!
就等着百度来收录吧!!

懒人自己来下载吧!!!
https://pan.baidu.com/s/1G7VZKLvojijswzenFYllkA   提取码 i9g7
相关专题
API数据接口
API数据接口
2022-11-010

API是开发中必不可少的知识点。API的合理应用可以大大节约开发成本。它收集了关于API接口的信息,包括API接口、API代码和API源代码,帮助你更快地学习和使用API技术。

版权声明:文章搜集于网络,如有侵权请联系本站,转载请说明出处:https://www.51yma.cn/jiaocheng/ECMS/243.html
文章来源: