Hello,
Does anyone know if updating an album via PHP is supported with Secure
Authsub? I've been able to authenticate properly with a secure
session token working, and create a new album, but as soon as I call
the save() method after updating the title on my createdEntry object,
I wind up getting a 403 as a response from the server with the
explanation being unknown authorization header. I'm using Zend PHP
1.8.4P1
Here's the sample code I modified to add the secure authsub...
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_Photos');
Zend_Loader::loadClass('Zend_Gdata_Photos_UserQuery');
Zend_Loader::loadClass('Zend_Gdata_Photos_AlbumQuery');
Zend_Loader::loadClass('Zend_Gdata_Photos_PhotoQuery');
session_start();
function setupClient($singleUseToken = null) {
$client = null;
// Fetch a new AuthSub token?
if (!$singleUseToken) {
$next = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER
['PHP_SELF'];
$scope = 'http://picasaweb.google.com/data';
$secure = 1;
$session = 1;
$authSubURL = Zend_Gdata_AuthSub::getAuthSubTokenUri($next,
$scope, $secure, $session);
echo '<a href="' . $authSubURL . '">Link your Google Picasa
Account and add a new album</a>';
}
else {
$client = new Zend_Gdata_HttpClient();
// This sets your private key to be used to sign subsequent
requests
$client->setAuthSubPrivateKeyFile('myrsakey.pem', null, true);
$sessionToken = Zend_Gdata_AuthSub::getAuthSubSessionToken(trim
($singleUseToken), $client);
// Set the long-lived session token for subsequent requests
$client->setAuthSubToken($sessionToken);
}
return $client;
}
function createPhotosObject($client) {
echo "CreatePhotosObject";
$photos = new Zend_Gdata_Photos($client,"Custom PWA client 0.25");
$photos->enableRequestDebugLogging('gphotos_requests.log');
return($photos);
}
$client = setupClient(@$_GET['token']);
if ($client) {
$photos = createPhotosObject($client);
$entry = new Zend_Gdata_Photos_AlbumEntry();
$entry->setTitle($photos->newTitle("Signed AuthSub"));
$entry->setSummary($photos->newSummary("This album was created via
AuthSub...Signed"));
$createdEntry = $photos->insertAlbumEntry($entry);
$createdEntry->title->text = "Changed to updated title";
$updatedEntry = $createdEntry->save();
}
else {
exit(); // Just display the AuthSub link
}
?>
The PHP error I get when the page is submitted is...
Unknown authorization header
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with
message 'Expected response code 200, got 403 Unknown authorization
header' in /nfs/c03/h01/mnt/49009/etc/library/Zend/Gdata/App.php:699
Stack trace: #0 /nfs/c03/h01/mnt/49009/etc/library/Zend/Gdata/App.php
(910): Zend_Gdata_App->performHttpRequest('PUT', 'http://picasawe...',
Array, '<atom:entry xml...', 'application/ato...') #1 /nfs/c03/h01/mnt/
49009/etc/library/Zend/Gdata/App.php(991): Zend_Gdata_App->put(Object
(Zend_Gdata_Photos_AlbumEntry), NULL, NULL, NULL, Array) #2 /nfs/c03/
h01/mnt/49009/etc/library/Zend/Gdata/App/Entry.php(208):
Zend_Gdata_App->updateEntry(Object(Zend_Gdata_Photos_AlbumEntry),
NULL, NULL, Array) #3 /nfs/c03/h01/mnt/49009/domains/mydomain.com/html/
admin/gjef3.php(54): Zend_Gdata_App_Entry->save() #4 {main} thrown in /
nfs/c03/h01/mnt/49009/etc/library/Zend/Gdata/App.php on line 699
In my gphotos_requests.log I wind up with the following as the
response from the server....
HTTP/1.1 403 Forbidden
Content-Type: text/plain
Transfer-Encoding: chunked
Date: Wed, 29 Jul 2009 02:43:52 GMT
Cache-control: private, must-revalidate, max-age=0
X-Content-Type-Options: nosniff
Set-Cookie: S=photos_html=vKrYF6y95QY6UHaKwNzCpw; Domain=.google.com;
Path=/; HttpOnly
Connection: close
Server: GFE/2.0
1C
Any help would be greatly appreciated.
Thanks!!!
Lee
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Picasa-Data-API?hl=en
-~----------~----~----~----~------~----~------~--~---