好到目前为止,我已经能够使用Google Feed显示来自用户/相册的缩略图。一切都显示正常,除非我想要显示更大的缩略图。我似乎无法显示大图像,不知道在这里使用什么......这是我的代码:
<?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>';
答案 0 :(得分:4)
每张照片的Feed / api包含3张拇指和一张大图片,可在以下原生http rest api上访问:
"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"
}
将客户端编码为底层REST api时,通常可以帮助您更好地掌握本机协议以及线路上的字符流(请求/响应)。然后你将PHP / Curl改编为http协议中的内容。
谷歌oauth游乐场是一个很棒的工具,用于测试针对任何gdata apis(包括picasa)开发所涉及的来回对话... ...
这是获取拇指的游乐场请求代码和给定相册/照片的大图片...
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
以及对上述内容的回应通过一张漂亮的印刷品......
"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
答案 1 :(得分:2)
您可以使用imgmax参数指定大小(imgmax = d表示原始图像)。 https://developers.google.com/picasa-web/docs/2.0/reference#Parameters
答案 2 :(得分:1)
您是否尝试过print_r($ album_photo)来检查对象的确切格式及其包含的内容?
我很确定您可以在该API中指定一些其他参数来访问不同大小的图片和缩略图。检查文档。
我之前使用json-script格式访问过此API,从内存中可以指定很多选项。
答案 3 :(得分:1)
我已经搜遍整个互联网,试图找到这个问题的答案。实际上没有人回答这个问题。为了将来参考任何其他阅读或我未来的自我,以获得大图像:
echo $album_photo->content->attributes()->{'src'};
这是WAAAAYY比它应该更复杂,普通的XML用户可能已经知道如何做到这一点。 :/