2

Ok so far I have been able to show thumbnails from user/album using the google feed. Everything displays ok, except when I want to show the thumbnail image larger. I can't seem to get the large image to show, not sure what to use here..here's my code:

<?php
$user = '100483307985144997386';
$albumid = '5092093264124561713';
$picasaURL = "http://picasaweb.google.com/$user/";
$albumfeedURL = "http://picasaweb.google.com/data/feed/api/user/$user/albumid/$albumid";

$sxml_album = simplexml_load_file($albumfeedURL);
echo '<table cellpadding="3" cellspacing="3">';
echo "<tr>";
$i = 0;
foreach( $sxml_album->entry as $album_photo )
{   

   //$title = $album_photo->title;
    $summary = $album_photo->summary;
    // Write thumbnail to file
    $media = $album_photo->children('http://search.yahoo.com/mrss/');
    $thumbnail = $media->group->thumbnail[1];

    $gphoto = $album_photo->children('http://schemas.google.com/photos/2007/');
    $linkName = $gphoto->group->attributes()->{'url'};    
    // Direct address to thumbnail
    $thumbAddy = $thumbnail->attributes()->{'url'};    
    if($i%4==0) { echo '</tr><tr>'; } 

    echo '<td style="width:90px; overflow:hidden; word-wrap:break-word; font-size:12px;">';
    echo '<a class="fancybox-buttons" data-fancybox-group="button" href="'. $linkName . '"><img src="'. $thumbAddy . '" /></a>';         
    echo '<p>'. $summary . '</p></td>';
    $i++; 
}

echo '</tr></table>';
Andres
  • 2,013
  • 6
  • 42
  • 67

4 Answers4

4

the feed/api for each photo contains 3 thumbs and a large picture which are accessible on the native http rest api in the following:

"media$thumbnail":[
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s72/DSC01612.JPG",
"height":72,
"width":48
},
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s144/DSC01612.JPG",
"height":144,
"width":96
},
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s288/DSC01612.JPG",
"height":288,
"width":192
}
],

LARGE ONE:

"media$group":{
"media$content":[
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/DSC01612.JPG",
"height":512,
"width":341,
"type":"image/jpeg",
"medium":"image"
} 

similar reference

When coding clients to an underlying REST api it can often help to have a good grasp on the native protocol and what character streams ( request / response ) are on the wire. Then you adapt PHP/Curl to what is there in http protocol.

The google oauth playground is a great tool for testing the back and forth dialogs involved in development against any of the gdata apis ( including picasa )...

playground

here is the playground request code to get the thumbs and the large pic for a given album/photo...

GET //data/entry/api/user/rowntreerob/albumid/5682316071017984417/photoid/5682316083381958690?fields=media%3Agroup%2Fmedia%3Athumbnail%5B%40url%5D%2Cmedia%3Agroup%2Fmedia%3Acontent%5B%40url%5D&alt=json HTTP/1.1


Host: picasaweb.google.com
Authorization: OAuth ya29.AHES6ZT123y3Y5Cy3rILYg4Ah4q....
HTTP/1.1 200 OK
status: 200
gdata-version: 1.0
content-length: 756
x-xss-protection: 1; mode=block
content-location: https://picasaweb.google.com//data/entry/api/user/rowntreerob/albumid/5682316071017984417/photoid/5682316083381958690?fields=media%3Agroup%2Fmedia%3Athumbnail%5B%40url%5D%2Cmedia%3Agroup%2Fmedia%3Acontent%5B%40url%5D&alt=json
x-content-type-options: nosniff
set-cookie: _rtok=a1p2m3PiHFkc; Path=/; Secure; HttpOnly, S=photos_html=sX3EHuLxGEre_OMvR0LTPg; Domain=.google.com; Path=/; Secure; HttpOnly
expires: Wed, 16 May 2012 03:23:51 GMT
vary: Accept, X-GData-Authorization, GData-Version, Cookie
x-google-cache-control: remote-fetch
-content-encoding: gzip
server: GSE
last-modified: Fri, 06 Jan 2012 17:57:33 GMT
via: HTTP/1.1 GWA
cache-control: private, max-age=0, must-revalidate, no-transform
date: Wed, 16 May 2012 03:23:51 GMT
access-control-allow-origin: *
content-type: application/json; charset=UTF-8
x-frame-options: SAMEORIGIN

and the response to the above run thru a prettyprint...

"version":"1.0",
"encoding":"UTF-8",
"entry":{
"xmlns":"http://www.w3.org/2005/Atom",
"xmlns$media":"http://search.yahoo.com/mrss/",
"media$group":{
"media$content":[
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/DSC01612.JPG",
"height":512,
"width":341,
"type":"image/jpeg",
"medium":"image"
}
],
"media$thumbnail":[
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s72/DSC01612.JPG",
"height":72,
"width":48
},
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s144/DSC01612.JPG",
"height":144,
"width":96
},
{
"url":"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s288/DSC01612.JPG",
"height":288,
"width":192
Community
  • 1
  • 1
Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43
  • Thank you, it cleared it up in a way. So going by what you explained I did this: $linkName = $media->group->content->attributes()->{'url'}; and I am getting a larger image than the thumbnails, although not convinced its the absolute true fullsize image but I'm happy with it for now. If I am wrong please still let me know. – Andres May 16 '12 at 14:14
  • in general, you need to know the data schema, how to refer to entities & attributes using xsl notation, and the details of your language (PHP). i cant help with php details , but the xsl field you want from the feed is media:group/media:content[@url]. im guessing , but it looks as tho you have that correct.. other links: https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol#Auth http://javadoc.google-api-java-client.googlecode.com/hg/1.0.10-alpha/com/google/api/client/googleapis/xml/atom/package-summary.html – Robert Rowntree May 16 '12 at 16:01
  • thanks, sometimes we expect the answer to just be handed to us to avoid taking the time out to read a little ;) but this really helped, and to be honest i did it with a lot of trial and error..lol but using your info. – Andres May 16 '12 at 16:24
2

You can specify the size by using imgmax parameter (imgmax=d means original image). https://developers.google.com/picasa-web/docs/2.0/reference#Parameters

1

Have you tried a print_r( $album_photo ) to check the exact format of the object and what it contains?

I'm pretty sure that there are a bunch of other parameters you can specify in that API to get access to different sizes of pictures and thumbnails. Check the docs.

I've accessed this API using json-script format a while ago and from memory there are a lot of options you can specify.

Sp4cecat
  • 991
  • 1
  • 8
  • 18
  • ok i get this: [content] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => image/jpeg [src] => http://lh5.ggpht.com/-MugLOHdTwDE/Rqq_5TtNyUI/AAAAAAAAALA/i9xx6XtiZFc/IMG_4499.jpg ) ) but not quite sure how to use it :S – Andres May 15 '12 at 00:40
  • that link is the large picture. use curl or whatever to get it and you have the large photo – Robert Rowntree May 16 '12 at 16:03
  • thanks, i was able to figure out how and from where to get the url from but this most definatly helped. – Andres May 16 '12 at 16:25
1

I have scoured the entire internet trying to find an answer to this problem. Nobody actually answered the question. For future reference to anyone else reading, or my future self, to get the large image do this:

echo $album_photo->content->attributes()->{'src'};

That was WAAAAYY more complicated than it should have been, and the normal XML user probably would have already known how to do that. :/