【问题标题】:Python: Google Contacts API only retrieving 3 contactsPython:Google Contacts API 仅检索 3 个联系人
【发布时间】:2016-02-10 11:02:53
【问题描述】:

我是 Python 和 Google API 的新手。

我有来自https://developers.google.com/google-apps/contacts/v3/?hl=en的以下代码:

def PrintAllContacts(gd_client):
  feed = gd_client.GetContacts()
  for i, entry in enumerate(feed.entry):
    print '\n%s %s' % (i+1, entry.name.full_name.text)
    if entry.content:
      print '    %s' % (entry.content.text)
    # Display the primary email address for the contact.
    for email in entry.email:
      if email.primary and email.primary == 'true':
        print '    %s' % (email.address)
    # Show the contact groups that this contact is a member of.
    for group in entry.group_membership_info:
      print '    Member of group: %s' % (group.href)
    # Display extended properties.
    for extended_property in entry.extended_property:
      if extended_property.value:
        value = extended_property.value
      else:
        value = extended_property.GetXmlBlob()
      print '    Extended Property - %s: %s' % (extended_property.name, value)

这仅返回 c 中的 3 个联系人。 850.有什么想法吗?

【问题讨论】:

    标签: python google-api gdata google-contacts-api gdata-python-client


    【解决方案1】:

    这行得通:

    def PrintAllContacts(gc):
        max_results = 20000
        start_index = 1
        query = gdata.contacts.client.ContactsQuery()
        query.max_results = max_results
        query.start_index = start_index
        feed = gc.GetContacts(q=query)
        print len(feed.entry)
        for e in feed.entry:
            print e.name
            for email in e.email:
                print email.address
    

    有用的链接:https://gdata-python-client.googlecode.com/hg/pydocs/gdata.contacts.data.html#ContactEntry

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-25
      • 2013-12-22
      相关资源
      最近更新 更多