Google /Baidu Ping服務快速收錄--php

來源:互聯網
上載者:User
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. }
複製代碼
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.