python - 谷歌照片 API 和获取单张照片
问题描述
我尝试从选定的专辑中获取照片,这就是为什么我只想在给定的专辑 ID 中列出 mediaItems。然而,这并没有改变,只是返回 400 http 代码。albumId 是正确的,因为我首先通过 API 检查它,它也给了我
from __future__ import print_function
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
ALBUM_ID = "???"
# Setup the Photo v1 API
SCOPES = [
'https://www.googleapis.com/auth/photoslibrary.readonly',
'https://www.googleapis.com/auth/photoslibrary.sharing'
]
store = file.Storage('credentials.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('photoslibrary', 'v1', http=creds.authorize(Http()))
# Call the Photo v1 API
results = service.albums().get(albumId=ALBUM_ID,).execute()
print(results)
#json = '{"albumId":"%s","pageSize":100}' % ALBUM_ID
zison = '{"albumId":"%s"}' % ALBUM_ID
mediaItems = service.mediaItems().search(body=zison).execute()
print(mediaItems)
items = results.get('albums', [])
if not items:
print('No albums found.')
else:
print('Albums:')
for item in items:
print('{0} ({1})'.format(item['title'].encode('utf8'), item['id']))
列出此资源的正确方法应该是什么?
解决方案
推荐阅读
- google-cloud-platform - 如何在 Google Cloud ML Engine 上的 config.yaml 文件中添加用户特定参数
- laravel - Maatwebsite Laravel Excel 重复记录被删除
- c - select() 是否保证所有数据都可用于从套接字读取或仅部分数据
- kubernetes - 用于重新部署的 Terraform ConfigMap 哈希
- url - 从 URL 填写表格 - postget 或如何?
- azure - 使用 Azure 数据工厂 V2 按 LastModifiedDate 复制新的和更改的文件
- php - 如何使用 Axios 将 ReactJs 中的表单提交到 PHP 处理程序(PHP miler 到电子邮件表单数据)?
- java - 正则表达式根据第一次出现的允许分隔符拆分过滤器字符串并获取键、运算符、值
- php - 在 Wordpress 主题中更改“加载更多”按钮的最佳方法是什么?
- swift - 在 Internet 连接可用时将多个存储的数据从已保存的本地数据库发送到服务器 iOS