欢迎您光临10元资源网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!

discuz教程:PING快速实现百度秒收录

discuz教程:PING快速实现百度秒收录

  • 一、利用百度搜索引擎的PING RPC2服务功能来达到搜索引擎快速收录帖子(推荐)
  • 实现原理:
  • 根据百度站长平台的提示,网站程序可以通过PING RPC2服务自动提醒百度搜索引擎收录你的网站,实时收录的哦!
  • 实现办法:
  • 1、首先新建一个新文件,文件名自定,放Discuz! X论坛的根目录!要自定名字的原因是,虽然百度提倡这么干,但是你不能老重复的提交啊,老虎屁股动不得!所以改名,以免别人捣蛋,你的站K了啥的,就别赖我了!
  • 我这里暂定名为: ping_seo.php这里修改网址,将我的站点地址(http://bbs.yeacome.com)改为你的。
  • 开启了伪静态的ping.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://bbs.yeacome.com/</string></value></param>
  • <param><value><string>http://bbs.yeacome.com/thread-$canshu-1-1.html</string></value></param>
  • <param><value><string>http://bbs.yeacome.com/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://bbs.yeacome.com/thread-$canshu-1-1.html”);
  • }
  • else
  • {
  • header (“Location:http://bbs.yeacome.com/thread-$canshu-1-1.html#”);
  • }
  • ?>
  • 复制代码
  • 未启了伪静态的ping.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#”);
  • }
  • ?>
  • 复制代码
  • 2、修改文件source\include\post\post_newthread.php,
  • Discuz X2.0找到
  • showmessage(‘post_newthread_succeed’, “forum.php?mod=viewthread&tid=$tid&extra=$extra”, $param);
  • 复制代码
  • 替换为(其中ping_seo为你自己的自定义ping文件名称):
  • showmessage(‘post_newthread_succeed’, “ping_seo.php?action=$tid”, $param);
  • 复制代码
  • DZX2.5找到:
  • showmessage(‘post_newthread_succeed’, $returnurl, $values, $param);
  • 复制代码
  • 替换为(其中ping_seo为你自己的自定义ping文件名称):
  • showmessage(‘post_newthread_succeed’, “ping文件的文件名称.php?action=$tid”, $values, $param);
  • 复制代码
  • OK,简单两步完成,需要花冤枉钱么?
  • Tips:
  • 如果PING失败,那么你发新帖后跳转的网址最后面会有一个#号!
  • 测试是否PING成功,也可以访问http://你的DZX网址/ping文件的文件名称.php?action=任意新帖子ID,不成功的话,网址后面会有#号。
  • 今天的教程就到这里,大家有什么疑问欢迎来提问。

大资源网 » discuz教程:PING快速实现百度秒收录

发表评论

售后服务:

  • 售后服务范围 1、商业模板使用范围内问题免费咨询
    2、源码安装、模板安装(一般 ¥200-1000)服务答疑仅限SVIP用户
    3、单价超过1000元的模板免费一次安装,需提供服务器信息。
    付费增值服务 1、提供dedecms模板、WordPress主题、discuz模板优化等服务请详询在线客服
    2、承接 WordPress、DedeCMS、Discuz 等系统建站、仿站、开发、定制等服务
    3、服务器环境配置(一般 ¥50-300)
    4、网站中毒处理(需额外付费,500元/次/质保三个月)
    售后服务时间 周一至周日(法定节假日除外) 9:00-23:00
    免责声明 本站所提供的模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: 263795763@qq.com),我们会及时删除,给您带来的不便,我们深表歉意!

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系作者
';