• 技术文章 >后端开发 >php教程

    Google /Baidu Ping服务快速收录--php

    2016-07-25 08:51:03原创581
    Google /Baidu Ping服务快速收录

    http://www.phperzone.cn/portal.php?mod=view&aid=743
    1. /**
    2. +------------------------------------------------------------------------------
    3. * 通知搜索引擎过来抓去最新发布的内容。秒收不是梦
    4. * 目前仅支持Google和Baidu
    5. +------------------------------------------------------------------------------
    6. */
    7. class ping {
    8. public $method, $callback;
    9. public function method($site_name, $site_url, $update_url, $update_rss) {
    10. $this->method = "
    11. weblogUpdates.extendedPing
    12. {$site_name}
    13. {$site_url}
    14. {$update_url}
    15. {$update_rss}
    16. ";
    17. return $this->method;
    18. }
    19. public function _post($url, $postvar) {
    20. $ch = curl_init();
    21. $headers = array(
    22. "POST " . $url . " HTTP/1.0",
    23. "Content-type: text/xml;charset="utf-8"",
    24. "Accept: text/xml",
    25. "Content-length: " . strlen($postvar)
    26. );
    27. curl_setopt($ch, CURLOPT_URL, $url);
    28. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    29. curl_setopt($ch, CURLOPT_POST, 1);
    30. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    31. curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
    32. $res = curl_exec($ch);
    33. curl_close($ch);
    34. return $res;
    35. }
    36. public function google() {
    37. $this->callback = $this->_post('http://blogsearch.google.com/ping/RPC2', $this->method);
    38. return strpos($this->callback, "0") ? true : false;
    39. }
    40. public function baidu() {
    41. $this->callback = $this->_post('http://ping.baidu.com/ping/RPC2', $this->method);
    42. return strpos($this->callback, "0") ? true : false;
    43. }
    44. }
    复制代码
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:Google /Baidu Ping服务快速收录--php
    上一篇:轻云建站,为何这么火爆。 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • php对称加解密的5个问答小结• 想请问一下印证的有关问题• php 之 cookie 跟 session 简单解读(笔记) • xml转换成数组的有关问题 • 注册信息添加到数据库,该怎么处理
    1/1

    PHP中文网