请求数据馈送时无法使用 PHP 检索 Picasa 照片


unable to retrieve picasa photos with php when requesting data feed

我试图从我的 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"}}}

没有关于照片的数据。 当我用另一个帐户尝试这个示例时,它可以工作。我验证了这些照片是公开的。

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

也许你当时那里没有公开的照片......

不相关的回答

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

对于所有 Picasa 网络相册 api 查询,alt=json-in-code 和/userid/default/必须提供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);