mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
FIX: Replace HTTP::sendRequest call
- HTTP::sendRequest() is gone from the HTTP class - Substitute slightly simpler code in a protected self::send_ping() method
This commit is contained in:
parent
079b949bf2
commit
378258b0e3
@ -208,15 +208,33 @@ class GoogleSitemap extends Controller {
|
|||||||
'sitemap.xml'
|
'sitemap.xml'
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = HTTP::sendRequest(
|
$response = self::send_ping(
|
||||||
"www.google.com",
|
"www.google.com", "/webmasters/sitemaps/ping", sprintf("sitemap=%s", $location)
|
||||||
"/webmasters/sitemaps/ping",
|
|
||||||
sprintf("sitemap=%s", $location)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an HTTP request to the host.
|
||||||
|
*
|
||||||
|
* @return String Response text
|
||||||
|
*/
|
||||||
|
protected static function send_ping($host, $path, $query) {
|
||||||
|
$socket = fsockopen($host, $port, $errno, $error);
|
||||||
|
if (!$socket) {
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
if ($query) {
|
||||||
|
$query = '?' . $query;
|
||||||
|
}
|
||||||
|
$request = "GET {$path}{$query} HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n\r\n";
|
||||||
|
fwrite($socket, $request);
|
||||||
|
$response = stream_get_contents($socket);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable pings to google.com whenever sitemap changes.
|
* Enable pings to google.com whenever sitemap changes.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user