zoukankan      html  css  js  c++  java
  • Google /Baidu Ping服务快速收录php

    玩过WORDPRESS的朋友应该都知道ping服务吧,通俗点讲它可以在更新文章的时候向Google、baidu及其他支持ping的搜索引擎发送指令然后招呼它们过来,不用傻等他们过来收录了,化被动为主动了。直接贴代码了,很简单的。

    /**
      +------------------------------------------------------------------------------
     * 通知搜索引擎过来抓去最新发布的内容。秒收不是梦
     * 目前仅支持Google和Baidu
      +------------------------------------------------------------------------------
     */
    class ping {
      
        public $method, $callback;
      
        public function method($site_name, $site_url, $update_url, $update_rss) {
            $this->method = "
      <?xml version="1.0" encoding="UTF-8"?>
      <methodCall>
        <methodName>weblogUpdates.extendedPing</methodName>
        <params>
       <param><value>{$site_name}</value></param>
       <param><value>{$site_url}</value></param>
       <param><value>{$update_url}</value></param>
       <param><value>{$update_rss}</value></param>
        </params>
      </methodCall>";
            return $this->method;
        }
      
        public function _post($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;
        }
      
        public function google() {
            $this->callback = $this->_post('http://blogsearch.google.com/ping/RPC2', $this->method);
            return strpos($this->callback, "<boolean>0</boolean>") ? true : false;
        }
      
        public function baidu() {
            $this->callback = $this->_post('http://ping.baidu.com/ping/RPC2', $this->method);
            return strpos($this->callback, "<int>0</int>") ? true : false;
        }
      
    }

    事实上

    转载:水平凡's Blog » Google /Baidu Ping服务快速收录[Php实现]

  • 相关阅读:
    Vue 组件化开发之插槽
    Vue 组件化开发
    Vue 双向绑定
    Vue 数组响应
    Vue 分支循环
    万字长文,详解推荐系统领域经典模型FM因子分解机
    操作失误不要慌,这个命令给你的Git一次反悔的机会
    codeforces 1425E,一万种情况的简单题
    计算机专业的学生要怎样做才能避免成为低级的码农?
    推荐系统,深度论文剖析GBDT+LR
  • 原文地址:https://www.cnblogs.com/blogsme/p/3076415.html
Copyright © 2011-2022 走看看