创建新的联系人Google People API

2024-04-23 20:19:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我的向导是: 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()

运行时,我的错误:

^{pr2}$

我得到了这个错误。如何有效地创建新联系人?在


Tags: 代码httpscomhttpmain错误servicegoogle
2条回答

问题解决了,虽然我不明白为什么。我可以通过以下方式保存联系人:

contact2 = service.people().createContact(
        body={"names": [{"givenName": "John", "familyName": "Doe"}]})

contact2.execute()

你的问题是这条线: contact2()service.people().createContact返回dictionary作为响应,而您正试图调用它。在

dictionary对象不是函数。在

相关问题 更多 >