You are here

function xmlsitemap_engines_submit_sitemap in XML sitemap 5.2

Same name and namespace in other branches
  1. 6 xmlsitemap_engines/xmlsitemap_engines.module \xmlsitemap_engines_submit_sitemap()

Submit the sitemap to the selected engine, and log the result.

Parameters

$engine: The identifier for the search engine.

$url_var: The variable name containing the submission URL used by the search engine.

$default_url: The default submission URL.

1 call to xmlsitemap_engines_submit_sitemap()
xmlsitemap_engines_xmlsitemap_engines in xmlsitemap_engines/xmlsitemap_engines.module
Implementation of hook_xmlsitemap_engines().

File

xmlsitemap_engines/xmlsitemap_engines.module, line 268
Defines actions for Google, Yahoo!, Ask, and Windows Live.

Code

function xmlsitemap_engines_submit_sitemap($engine, $url_var, $default_url) {
  $url = strtr(variable_get($url_var, $default_url), array(
    '[sitemap]' => url('sitemap.xml', NULL, NULL, TRUE),
  ));
  $result = drupal_http_request($url);
  if ($result->code == 200) {
    watchdog('xmlsitemap', t('The sitemap has been successfully submitted to !engine.', array(
      '!engine' => $engine,
    )));
  }
  else {
    watchdog('xmlsitemap', t('An error occurred while submitting the sitemap to !engine: !code', array(
      '!engine' => $engine,
      '!code' => 0 + $result->code,
    )), WATCHDOG_ERROR);
  }
}