【问题标题】:Get images from Google Plus album - Authentification从 Google Plus 相册中获取图片 - 身份验证
【发布时间】:2013-08-21 17:36:28
【问题描述】:
有没有办法从 Google Plus 相册中获取图片,例如以 JSON 格式。关于这些主题:
方法是使用 Picasa URL。这非常有效,但仅适用于公共相册
在 URL 中使用 authkey 不起作用。
http://picasaweb.google.com/data/feed/api/user/ ... 用户 ID ... /album/ ... 专辑 ID ... ?authkey= ... 身份验证密钥 ... &alt= json
有没有人有解决方案来获取不公开相册的 Google Plus 相册图片(使用 authkey)。
谢谢。
【问题讨论】:
标签:
image
google-plus
photos
picasa
【解决方案1】:
您可以通过 google plus 进行授权,然后使用其令牌从 Picasa 请求相册。
要获得正确的权限,您应该使用具有相应范围的 gapi.auth.authorize 方法,即 https://picasaweb.google.com/data/
var googleClientToken = ''
var options = {
client_id: googleClientId,
scope: 'https://picasaweb.google.com/data/ https://www.googleapis.com/auth/userinfo.email'
}
gapi.auth.authorize(options, function() {
googleAccessToken = gapi.auth.getToken().access_token
})
然后只需获取 url https://picasaweb.google.com/data/feed/api/user/USER_EMAIL/?kind=album&access_token=ACCESS_TOKEN&alt=json&access=all'
【解决方案2】:
您可以使用 PicasaWeb GData API:
- 列出用户的所有相册
- 确定您关心的相册的 ID
- 使用 alt=json 获取该专辑的数据