PHP的Picasa API秀大图 [英] php picasa api show large image

查看:178
本文介绍了PHP的Picasa API秀大图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,到目前为止我已经能够显示利用谷歌饲料从用户/相册缩略图。一切都显示正常,除非我想显示缩略图更大。我似乎无法得到大的图像显示,不知道该用什么here..here是我的code:

 < PHP
$ USER ='100483307985144997386';
$ ALBUMID ='5092093264124561713';
$ picasaURL =htt​​p://picasaweb.google.com/$user/;
$ albumfeedURL =htt​​p://picasaweb.google.com/data/feed/api/user/$user/albumid/$albumid;$ sxml_album =使用simplexml_load_file($ albumfeedURL);
呼应'<表格的cellpadding =3CELLSPACING =3>';
回声< TR>中;
$ I = 0;
的foreach($ sxml_album->条目$ album_photo)
{   // $标题= $ album_photo->称号;
    $总结= $ album_photo->摘要;
    //写缩略图文件
    $媒体= $ album_photo->儿童('http://search.yahoo.com/mrss/');
    $缩略图= $媒体 - >&组 - GT;缩略图[1];    $ gphoto = $ album_photo->儿童('http://schemas.google.com/photos/2007/');
    $ LINKNAME = $ gphoto->&组 - GT;属性() - GT; {'URL'};
    //直接地址缩略图
    $ thumbAddy = $ thumbnail->属性() - GT; {'URL'};
    如果($ I%4 == 0){回声'< / TR>< TR>'; }    呼应'< TD风格=宽度:90像素;溢出:隐藏;自动换行:打破字; FONT-SIZE:12px的;>';
    回声'&下;类别=的fancybox-按钮数据的fancybox基团=按钮的href ='$ LINKNAME。'>&下; IMG SRC ='$ thumbAddy'。/>&下; / A>';
    呼应'< P>'。 $总结。 '< / P>< / TD>';
    $ I ++;
}呼应'< / TR>< /表>';


解决方案

饲料/ API每张照片包含3个拇指大图片这是在以下的本机HTTP REST API访问:

 媒体$缩略图:[
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s72/DSC01612.JPG\",
高度:72,
宽:48
},
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s144/DSC01612.JPG\",
高度:144,
宽:96
},
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s288/DSC01612.JPG\",
高度:288,
宽:192
}
]大单:传媒集团$:{
媒体内容$:
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/DSC01612.JPG\",
高度:512,
宽:341,
类型:图像/ JPEG,
中:图像
}

<一个href=\"http://stackoverflow.com/questions/9935814/where-is-the-full-size-image-in-gdata-photos-query/10033029#10033029\">similar参考

在编码的客户一个基本的REST API,它往往可以帮助对本地协议,什么字符流(请求/响应)是在电线上把握好。然后,你适应PHP /卷曲什么HTTP协议是存在的。

在谷歌OAuth园地是检验来回参与开发的针对任何GData API与(包括Picasa)...

的对话框一个伟大的工具

游乐场

下面是操场请求code以获取给定的相册/照片拇指和大型图片...

  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
主持人:picasaweb.google.com
授权:OAuth的ya29.AHES6ZT123y3Y5Cy3rILYg4Ah4q ....
HTTP / 1.1 200 OK
状态:200
gdata的版本:1.0
内容长度:756
的X XSS防护:1;模式=块
内容定位: 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内容类型选项:nosniff
设置Cookie:_rtok = a1p2m3PiHFkc;路径= /;安全;仅Http,S = photos_html = sX3EHuLxGEre_OMvR0LTPg;域名= .google.com;路径= /;安全;仅Http
到期日:星期三,2012 GMT 3点23分51秒5月16日
各不相同:接受,X-的GData的授权,的GData-版本,饼干
的x谷歌缓存控制:远程取
编码-content-:gzip的
服务器:GSE
最后一次修改:星期五,2012 01月06日17时57分33秒GMT
通过:HTTP / 1.1 GWA
缓存控制:私人,最大年龄= 0,必重新验证,无转换
日期:星期三,2012 GMT 3时23分51秒5月16日
访问控制允许来源:*
内容类型:应用程序/ JSON的;字符集= UTF-8
X框选项:SAMEORIGIN

和响应于上述运行直通一个prettyprint ...

 版本:1.0,
编码:UTF-8,
条目:{
的xmlns:http://www.w3.org/2005/Atom,
的xmlns $媒体:http://search.yahoo.com/mrss/
传媒集团$:{
媒体内容$:
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/DSC01612.JPG\",
高度:512,
宽:341,
类型:图像/ JPEG,
中:图像
}
]
媒体$缩略图:[
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s72/DSC01612.JPG\",
高度:72,
宽:48
},
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s144/DSC01612.JPG\",
高度:144,
宽:96
},
{
\"url\":\"https://lh3.googleusercontent.com/-_FFMNGPU1TQ/TtukXyN4eCI/AAAAAAAACso/EzPmut2iKVQ/s288/DSC01612.JPG\",
高度:288,
宽:192

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>';

解决方案

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

这篇关于PHP的Picasa API秀大图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆