【发布时间】:2021-12-29 00:22:59
【问题描述】:
我正在使用 Python 中的 Google People API 来查询我的 Google 联系人列表。我可以让这个功能工作,但一个特定的操作不起作用。
results = service.people().connections().list(
resourceName='people/me',
pageSize=1,
personFields='names,phoneNumbers').execute()
connections = results.get('connections', [])
for person in connections:
data = person.get('names', [])
这很有效——它给了我一个名字列表。但是,我想要一份姓名和电话号码的列表。如果我这样做:
for person in connections:
data = person.get('phoneNumbers', [])
这也有效。我得到一个电话号码列表。但是,如果我尝试同时获得两者,我不会得到任何结果:
for person in connections:
data = person.get('names,phoneNumbers', [])
根据我对 People API 文档 (https://developers.google.com/people/api/rest/v1/people/get) 的解释,这应该可行。相反,我什么也得不到。
我做错了什么?
【问题讨论】:
标签: python google-api google-people-api