【问题标题】:Google Apps shared contacts API get a contact for pythonGoogle Apps 共享联系人 API 获取 python 联系人
【发布时间】:2010-03-30 13:52:17
【问题描述】:

我在尝试使用 Google 提供的用于 python 的 gdata api 提取共享联系人时遇到了一些问题。这是我必须得到的联系人.. 但他们并没有全部列在那里

feed = gd_client.GetContactsFeed()
for i, entry in enumerate(feed.entry):
    print entry.title

我不知道如何提取单个联系人以便编辑联系人信息..

谢谢!

【问题讨论】:

    标签: python google-api


    【解决方案1】:

    Google API 在这方面缺乏功能。
    您需要查询所有联系人,然后像这样对其进行迭代:

    feedquery = gdata.contacts.service.ContactsQuery()
    feedquery.query.max_results = 1000
    gmlf = gd_client.GetContactsFeed(feedquery.ToUri())
    for index,gmc in enumerate(gmlf.entry):
            print str(index) +":"+ gmc .title.text
    

    请记住根据您的需要设置query.max_results,因为默认设置为最多 25 个联系人; 这可能是原因,因为它们并未在您的查询之后全部列出。
    您无法检索一个特定的联系人;您需要检索所有并使用他们的电子邮件或标题过滤它们。

    【讨论】:

    • 我正在使用 v3.0 协议。GAE raise this:AttributeError: 'ContactsQuery' object has no attribute 'query' 该行应根据code.google.com/apis/contacts/docs/3.0/…更改为 feedquery.max_results = 1000跨度>
    猜你喜欢
    • 2015-10-09
    • 2012-07-07
    • 1970-01-01
    • 1970-01-01
    • 2015-10-15
    • 1970-01-01
    • 2018-02-22
    • 2012-10-02
    • 1970-01-01
    相关资源
    最近更新 更多