Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Submit unlimited sitemaps to Google Webmaster Tools at once - with just one single call: new GWT_SitemapsUpload($sitemaps);
branch: master

Don't interpret leading '@'s in POST values.

Curl's default -F switch interprets a leading @ symbol for the value as an instruction to not POST the field/value data, but instead to send the file name that immediately succeeds the symbol (as part of the POST). In order to be able to use passwords starting with an @ symbol, POST data is now being send as application/x-www-form-encoded instead of multipart/form-data whenever a password value starts with an @ symbol. (See eyecatchup/GWT_CrawlErrors-php#8 for further reference.)
latest commit 31ee6ad27b
Stephan Schmitz authored
Failed to load latest commit information.
GWT_SitemapsUpload.php Don't interpret leading '@'s in POST values.
README.md Initial commit

README.md

GWT_SitemapsUpload: Submit XML Sitemaps to Google Webmaster Tools

With GWT_SitemapsUpload you can submit a bunch of XML Sitemaps to your Google Webmaster Tools Account at once. More specifically, you can submit unlimited sitemaps with just one single line - new GWT_SitemapsUpload($sitemaps);!

Usage

Interface

For the ease of use, set your account using the class interface GWT_Client

<?php
interface GWT_Client
{
    const Email = 'user@gmail.com';
    const Passwd = 'mysecretpassword';
    // Must have a trailing slash!
    const Website = 'http://www.domain.tld/';
}

Example Usage

<?php
try {
  /* Sitemaps to submit to Google Webmaster Tools.
   */
  $sitemaps = Array(
    'http://www.domain.tld/sitemaps/sitemap-1.xml',
    'http://www.domain.tld/sitemaps/sitemap-2.xml',
    'http://www.domain.tld/sitemaps/sitemap-3.xml',
    'http://www.domain.tld/sitemaps/sitemap-4.xml',
    'http://www.domain.tld/sitemaps/sitemap-5.xml',
    'http://www.domain.tld/sitemaps/sitemap-6.xml',
    'http://www.domain.tld/sitemaps/sitemap-7.xml',
    'http://www.domain.tld/sitemaps/sitemap-8.xml',
    'http://www.domain.tld/sitemaps/sitemap-9.xml',
    'http://www.domain.tld/sitemaps/sitemap-10.xml'
  );

  /** Example 1
   *  Just upload (assumes login via interface)
   */
    new GWT_SitemapsUpload($sitemaps); # Boom - that's it! :)


  /** Example 2
   *  Upload and Feedback (assumes login via interface)
   */
    $GWT = new GWT_SitemapsUpload($sitemaps);

    $transactions = $GWT->getTransactions();
    foreach ($transactions AS $request) {
        $sitemap = $request['Sitemap'];
        $response = $request['Response'];
        print "HTTP response for submit request of $sitemap: $response\n";
    }


  /** Example 3
   *  Login on create
   */
    $email   = 'user@gmail.com';
    $passwd  = 'mysecretpassword';
    $website = 'http://www.domain.tld/'; # Must have a trailing slash!

    $GWT = new GWT_SitemapsUpload();

    if ($GWT->login($email, $passwd) === TRUE) :
        foreach ($sitemaps AS $sitemap) {
            // Upload a new standard XML sitemap (Type "WEB")
            $response = $GWT->putSitemap($website, $sitemap);
            print "HTTP response for submit request of $sitemap: $response\n";
        }
    endif;

} catch (Exception $e) {
  die($e->getMessage());
}
Something went wrong with that request. Please try again.