Picasa网络相册API:照片源中start-index无效

0 投票
2 回答
510 浏览
提问于 2025-04-18 16:59

我正在从Picasa获取用户的最近上传的照片。在参数文档中提到,可以通过使用max-resultsstart-index的组合来分页响应。但是,这似乎没有效果。

下面是一些使用不同start-index的请求示例:

https://picasaweb.google.com/data/feed/api/user/myEmailId?kind=photo&max-results=5&alt=json&start-index=1&imgmax=d

https://picasaweb.google.com/data/feed/api/user/myEmailId?kind=photo&max-results=5&alt=json&start-index=6&imgmax=d

这两个请求返回的结果是一样的。start-index没有任何效果。

我在GData问题页面上发布了这个问题,但还没有得到任何回复。

我尝试的代码片段:

credentials = SignedJwtAssertionCredentials(
      SERVICE_ACCOUNT_EMAIL,
      file(SERVICE_ACCOUNT_PEM_FILE_PATH, "rb").read(),
      scope=["https://picasaweb.google.com/data/"],
      prn=userEmail
    )
PHOTOS_URL = "https://picasaweb.google.com/data/feed/api/user/%s?kind=photo&max-results=5&alt=json&start-index=%s&imgmax=d"
http = httplib2.Http()
http = credentials.authorize(http)
response, albumPhotos = http.request(PHOTOS_URL %(userEmail, startIndex), 'GET')
albumPhotos = eval(albumPhotos)

有没有什么想法?

2 个回答

0

查找 gphoto$numphotos 的值(也就是 response['feed']['entry']['gphoto$numphotos'])。获取到这个值后,你可以使用:

https://picasaweb.google.com/data/feed/api/user/default/albumid/{albmId}?start-index=VALUE
0

可以在这个链接试试:https://developers.google.com/oauthplayground.

在获取用户最近更新的照片时,https://picasaweb.google.com/data/feed/api/user/%s?kind=photo这个链接里的start-index参数并不好使,虽然返回的结果显示openSearch:startIndex确实接受了start-index参数。

不过,如果你查询的是某个特定相册里的照片,比如:https://picasaweb.google.com/data/feed/api/user/default/albumid/{albmId}?start-index=10,那这个参数就能正常工作了。

撰写回答