Google/BaiduPing服务快速收录--php
时间:2021-07-01 10:21:17
帮助过:44人阅读
Google /Baidu Ping服务快速收录
http://www.phperzone.cn/portal.php?mod=view&aid=743
- /**
- +------------------------------------------------------------------------------
- * 通知搜索引擎过来抓去最新发布的内容。秒收不是梦
- * 目前仅支持Google和Baidu
- +------------------------------------------------------------------------------
- */
- class ping {
-
- public $method, $callback;
-
- public function method($site_name, $site_url, $update_url, $update_rss) {
- $this->method = "
-
-
- weblogUpdates.extendedPing
-
- {$site_name}
- {$site_url}
- {$update_url}
- {$update_rss}
-
-
"; - 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, "0") ? true : false;
- }
-
- public function baidu() {
- $this->callback = $this->_post('http://ping.baidu.com/ping/RPC2', $this->method);
- return strpos($this->callback, "0") ? true : false;
- }
-
- }
|