【发布时间】:2017-10-26 07:34:09
【问题描述】:
我按照指南进行操作: https://developers.google.com/people/v1/write-people
我的代码:
def main():
"""Shows basic usage of the Google People API
"""
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('people', 'v1', http=http,
discoveryServiceUrl='https://people.googleapis.com/$discovery/rest')
contact2 = service.people().createContact(
body={"names": [{"givenName": "John", "familyName": "Doe"}]}).execute()
contact2()
if __name__ == '__main__':
main()
当我运行时,我的错误:
~/quickstart.py
Traceback (most recent call last):
File "~/quickstart.py", line 77, in <module>
main()
File "~/quickstart.py", line 66, in main
contact2()
TypeError: 'dict' object is not callable
Process finished with exit code 1
我收到此错误。如何有效地创建新联系人?
【问题讨论】:
-
请提供完整的追溯。该错误可能在代码中的任何地方发生
-
我认为这就是完整的追溯..
-
contact2 是字典,不是函数,所以不能调用。我不知道 API,但我敢打赌
execute()方法会返回一个字典,其中包含对您的请求的响应。 -
我的目的是创建一个联系人。如果我调用contact2.execute(),它确实创建并保存了。所以问题现在解决了。非常感谢您的帮助!
-
该 api 已被 google 弃用。见['链接到公告'](developers.google.com/contacts/v3/announcement)
标签: python google-people-api google-python-api