0

我试图从我的 picasa 帐户中检索最新的 10 张照片,但它不起作用。

$file = file_get_contents("http://picasaweb.google.com/data/feed/api/user/firdawsfm?kind=photo&max-results=10&alt=json&access=public&thumbsize=".$tSize);
print_r($file);

结果 :

     {"$t":"http://picasaweb.google.com/data/feed/api/user/firdawsfm"},"updated":{"$t":"2013-09-08T19:27:11.010Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind",
    "term":"http://schemas.google.com/photos/2007#user"}],
    "title":{"$t":"108451527358440546192","type":"text"},
    "subtitle":{"$t":"","type":"text"},
    "icon":{"$t":"http://lh3.ggpht.com/-Srl88atqmQE/AAAAAAAAAAI/AAAAAAAAAAA/AhcCTIASEAM/s64-c/108451527358440546192.jpg"},
"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml",
"href":"http://picasaweb.google.com/data/feed/api/user/108451527358440546192?alt=json"},{"rel":"alternate",
"type":"text/html",
    "href":"https://picasaweb.google.com/108451527358440546192"},{"rel":"http://schemas.google.com/photos/2007#slideshow",
"type":"application/x-shockwave-flash",
"href":"https://static.googleusercontent.com/external_content/picasaweb.googleusercontent.com/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http://picasaweb.google.com/data/feed/api/user/108451527358440546192?alt%3Drss"},{"rel":"self","type":"application/atom+xml",
"href":"http://picasaweb.google.com/data/feed/api/user/108451527358440546192?alt=json&q=&start-index=1&max-results=10&kind=photo&thumbsize=180c&access=public"}],
"author":[{"name":{"$t":"Firdaws Haskell"},"uri":{"$t":"https://picasaweb.google.com/108451527358440546192"}}],
    "generator":{"$t":"Picasaweb",
    "version":"1.00",
    "uri":"http://picasaweb.google.com/"},
    "openSearch$totalResults":{"$t":0},
    "openSearch$startIndex":{"$t":1},"openSearch$itemsPerPage":{"$t":10},
    "gphoto$user":{"$t":"108451527358440546192"},"gphoto$nickname":{"$t":"Firdaws Haskell"},"gphoto$thumbnail":{"$t":"http://lh3.ggpht.com/-Srl88atqmQE/AAAAAAAAAAI/AAAAAAAAAAA/AhcCTIASEAM/s64-c/108451527358440546192.jpg"}}}

没有关于照片的数据。当我使用另一个帐户尝试此示例时,它可以工作。我确认照片是公开的。

4

1 回答 1

2

我试过你的网址,一切正常,我可以访问 gphoti$id 和 media$group 值。到目前为止似乎一切正常;)再试一次!

可能你那个时候还没有公开的照片……

与该问题无关的答案

(如果服务器请求授权):

对于所有使用 alt=json 或 alt=json-in-code 和 /userid/default/ 的 Picasa 网络相册 API 查询,您必须提供 access_token 参数。

您可以使用 OAuth2 授权工作流程获取访问令牌,如下所述:

http://code.google.com/p/google-api-php-client/wiki/OAuth2(例如使用 google-api-php-client SDK)

并在范围内使用此值“ http://picasaweb.google.com/data/ ”。

请求用户登录后如何执行 OAuth2 并从https://accounts.google.com/o/oauth2/token获取访问令牌: https://accounts.google.com/o/oauth2/auth您可以在官方上找到网站: https ://developers.google.com/accounts/docs/OAuth2Login

最后你必须有:

$file = file_get_contents("http://picasaweb.google.com/data/feed/api/user/firdawsfm?kind=photo&max-results=10&alt=json&access=public&thumbsize=".$tSize."&access_token=".$access_token);
print_r($file);
于 2013-10-29T16:51:59.560 回答