zoukankan      html  css  js  c++  java
  • Discuz利用百度ping把我们网站自动提交到百度

    百度ping是一个提交RSS和博客网址到百度的一个百度官方工具,当然wordpress有这方面的插件,我就不多说的,在这里只说关于discuz的方法,当然discuz也有插件只不过要几十块大洋买才可以,这个功能呢可以自动向百度提交我们更新的文章或者帖子,从而可以达到秒收的效果,下面我们就来说一下步骤
     
    这个就是提交的网址:http://ping.baidu.com/ping.html
    这好似百度官方PING请求服务:http://zhanzhang.baidu.com/tools/ping
    首先新建一个新文件,文件名自定,放DZX论坛的根目录!
    要自定名字的原因是,虽然百度提倡这么干,但是你不能老重复的提交啊,老虎屁股动不得!所以改名,以免别人捣蛋,你的站K了啥的,就别赖我了!
    我这里暂定名为: ping.php
    这里修改网址,修改中文部分为你的!
    discuz开启了伪静态的ping.php代码用这个:
     
    PHP
    <?php
    if(isset($_GET['action']))
    {
    $canshu=$_GET['action'];
    }
     
    function postUrl($url, $postvar) 
    { 
        $ch = curl_init(); 
        $headers = array( 
            "POST ".$url." HTTP/1.0", 
            "Content-type: text/xml; charset="utf-8"", 
            "Accept: text/xml", 
            "Content-length: ".strlen($postvar) 
        ); 
        curl_setopt($ch, CURLOPT_URL, $url); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
        curl_setopt($ch, CURLOPT_POST, 1); 
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar); 
        $res = curl_exec ($ch); 
        curl_close ($ch); 
        return $res; 
    } 
     
    $baiduXML = "<?xml version="1.0" encoding="utf-8"?> 
       <methodCall> 
       <methodName>weblogUpdates.extendedPing</methodName> 
       <params> 
       <param><value><string>你的站名</string></value></param> 
       <param><value><string>http://你的DZX网址/</string></value></param> 
       <param><value><string>http://你的DZX网址/thread-$canshu-1-1.html</string></value></param> 
       <param><value><string>http://你的DZX网址/forum.php?mod=rss</string></value></param> 
       </params> 
       </methodCall>"; 
    $res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML); 
     
    if ( strpos($res, "<int>0</int>") ) 
    { 
            header ("Location:http://你的DZX网址/thread-$canshu-1-1.html");
    } 
    else 
    { 
            header ("Location:http://你的DZX网址/thread-$canshu-1-1.html#");
    } 
    ?>
     把里面相应的改成自己的网址
    如果你没开启dicuz伪静态的用这个:
     
    PHP
    <?php
    if(isset($_GET['action']))
    {
    $canshu=$_GET['action'];
    }
     
    function postUrl($url, $postvar) 
    { 
    $ch = curl_init(); 
    $headers = array( 
    "POST ".$url." HTTP/1.0", 
    "Content-type: text/xml; charset="utf-8"", 
    "Accept: text/xml", 
    "Content-length: ".strlen($postvar) 
    ); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar); 
    $res = curl_exec ($ch); 
    curl_close ($ch); 
    return $res; 
    } 
     
    $baiduXML = "<?xml version="1.0" encoding="utf-8"?> 
    <methodCall> 
    <methodName>weblogUpdates.extendedPing</methodName> 
    <params> 
    <param><value><string>你的站名</string></value></param> 
    <param><value><string>http://你的DZX网址/</string></value></param> 
    <param><value><string>http://你的DZX网址/forum.php?mod=viewthread&tid=$canshu</string></value></param> 
    <param><value><string>http://你的DZX网址/forum.php?mod=rss</string></value></param> 
    </params> 
    </methodCall>"; 
    $res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML); 
     
    if ( strpos($res, "<int>0</int>") ) 
    { 
    header ("Location:http://你的DZX网址/forum.php?mod=viewthread&tid=$canshu");
    } 
    else 
    { 
    header ("Location:http://你的DZX网址/forum.php?mod=viewthread&tid=$canshu#");
    } 
    ?>
     第二步:修改修改文件sourceincludepostpost_newthread.php文件
    discuz x2.0的方法
     
    找到
     
    PHP
    showmessage('post_newthread_succeed', "forum.php?mod=viewthread&tid=$tid&extra=$extra", $param);
    改成
     
    PHP
    showmessage('post_newthread_succeed', "文件的文件名称.php?action=$tid", $param);
    discuz x2.5的方法
     
    找到
    PHP
    showmessage('post_newthread_succeed', $returnurl, $values, $param);
    改成
     
    PHP
    showmessage('post_newthread_succeed', "文件名称.php?action=$tid", $values, $param);
    如果PING失败,那么你发新帖后跳转的网址最后面会有一个#号!
    测试是否PING成功,也可以访问http://你的DZX网址/ping文件的文件名称.php?action=任意新帖子ID,不成功的话,网址后面会有#号。
     
    大家都知道discuz的RSS地址不?
  • 相关阅读:
    再谈H2的MVStore与MVMap
    log4j动态日志级别调整
    wireshark抓文件上传的包的结果记录
    struts2对properties资源的处理
    Spring core resourc层结构体系及JDK与Spring对classpath中资源的获取方式及结果对比
    [工具使用] visualvm 通过jmx不能连接
    oracle 安装 启动listener 建库相关
    vscode
    XSSFWorkbook
    TearmQuery()
  • 原文地址:https://www.cnblogs.com/shanyansheng/p/5488337.html
Copyright © 2011-2022 走看看