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. ";
  12. return $this->method;
  13. }
  14. public function _post($url, $postvar) {
  15. $ch = curl_init();
  16. $headers = array(
  17. "POST " . $url . " HTTP/1.0",
  18. "Content-type: text/ "Accept: text/ "Content-length: " . strlen($postvar)
  19. );
  20. curl_setopt($ch, CURLOPT_URL, $url);
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22. curl_setopt($ch, CURLOPT_POST, 1);
  23. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  24. curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
  25. $res = curl_exec($ch);
  26. curl_close($ch);
  27. return $res;
  28. }
  29. public function google() {
  30. $this->callback = $this->_post('http://blogsearch.google.com/ping/RPC2', $this->method);
  31. return strpos($this->callback, "") ? true : false;
  32. }
  33. public function baidu() {
  34. $this->callback = $this->_post('http://ping.baidu.com/ping/RPC2', $this->method);
  35. return strpos($this->callback, "") ? true : false;
  36. }
  37. }
复制代码


08-27 04:08