Thanks for that, I'm trying to hack together something that works from the demo in the PHP files you can download from ZEND
I took the google Docs File and basically murdered it to try and find out what works. (some guesswork was involved),
This actually retrieves the site list- but I dont' know how?!?!
Authenticaion is being done first, then it retrieves the feed.
So step 1 getting a list of my sites from webmaster tools API with PHP is done, but pretty darn ugly, any takers on a simplified more elegant version of this?
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Docs');
session_start();
if (!isset($_SESSION['docsSampleSessionToken']) && !isset($_GET['token'])) {
requestUserLogin('Please login to your Google Account.');
} else {
$client = getAuthSubHttpClient();
$sites = new Zend_Gdata($client);
retrieveAllSites($sites, true);
}
function printSitesFeed($feed, $html)
{
echo "Called - printSitesFeed <BR>";
if ($html) {echo "<ul>\n";}
// Iterate over the document entries in the feed and display each document's
// title.
foreach ($feed->entries as $entry) {
if ($html) {
// Find the URL of the HTML view of the document.
$alternateLink = '';
foreach ($entry->link as $link) {
if ($link->getRel() === 'alternate') {
$alternateLink = $link->getHref();
}
}
// Make the title link to the document on docs.google.com.
echo "<li><a href=\"$alternateLink\">\n";
}
echo "$entry->title\n";
if ($html) {echo "</a></li>\n";}
}
if ($html) {echo "</ul>\n";}
}
function retrieveAllSites($client, $html)
{ echo "Called - retrieveAllSites <BR>";
if ($html) {echo "<h2>Your documents</h2>\n";}
$feed = $client -> getFeed('https://www.google.com/webmasters/tools/feeds/sites/');
//print_r($feed);
// $feed = $client->getDocumentListFeed();
printSitesFeed($feed, $html);
}
function requestUserLogin($linkText)
{
echo "Called - requestUserLogin <BR>";
$authSubUrl = getAuthSubUrl();
echo "<a href=\"{$authSubUrl}\">{$linkText}</a>";
}
function getAuthSubUrl()
{
echo "Called - getAuthSubUrl <BR>";
$next = getCurrentUrl();
$scope = 'https://www.google.com/webmasters/tools/feeds/sites/';
$secure = false;
$session = true;
return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure,$session);
}
function getAuthSubHttpClient()
{
echo "Called - getAuthSubHttpClient <BR>";
global $_SESSION, $_GET;
if (!isset($_SESSION['docsSampleSessionToken']) && isset($_GET['token'])) {
$_SESSION['docsSampleSessionToken'] =
Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
}
$client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['docsSampleSessionToken']);
print_r($client);
return $client;
}
function getCurrentUrl()
{
echo "Called - getCurrentUrl <BR>";
global $_SERVER;
/**
* Filter php_self to avoid a security vulnerability.
*/
$php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0,
strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES);
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
$host = $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != '' &&
(($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') ||
($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) {
$port = ':' . $_SERVER['SERVER_PORT'];
} else {
$port = '';
}
return $protocol . $host . $port . $php_request_uri;
}