[Solar-talk] new sitemap class
Rodrigo Moraes
rodrigo.moraes at gmail.com
Thu Jan 3 07:58:26 CST 2008
Hey Clay and all,
I made a quick ping() method for the sitemap. Notes:
- I supposed that most services will accept ping's through 'get';
- I haven't researched which uri's should we ping, but maybe it would
be a good idea to set a list of uri's formatted for sprintf()?
Below is the method; let me know if it can be improved or you think
that this would be enough.
-- rodrigo
/**
*
* Pings services to tell them about a new/updated sitemap.
*
* @var string $sitemap_url The full sitemap url to be ping'ed.
*
* @var array $ping_urls List of service url's to ping, formatted to be
* used by sprintf. A placeholder (%s) will be replaced by the sitemap url.
*
* @return array $res A list of the service url's mapping to the the status
* code they returned.
*
*/
public function ping($sitemap_url, $ping_urls = null)
{
$res = array();
if (! $ping_urls) {
$ping_urls = $this->_config['ping'];
}
$request = Solar::factory('Solar_Http_Request', $this->_config['http']);
foreach ($ping_urls as $ping_url) {
// Build the uri.
$uri = sprintf($ping_url, $sitemap_url);
// ping!
$response = $request->setUri($uri)->setMethod('get')->fetch();
$res[$ping_url] = $response->getStatusCode();
}
return $res;
}
More information about the Solar-talk
mailing list