Search code examples
gdata-apigoogle-contacts-api

gdata get contacts from a certain group


How can I retrieve all my contacts that belong to a certain group? I don't want a complete list of all my contacts just the ones from a specific group.

This is the group: DEBUG 2009-07-28 12:01:32,681 helloworld.py:21] group is Customers with id http://www.google.com/ m8/feeds/groups/XXXX%40gmail.com/base/XXXX


Solution

  • I found the answer, should any one run into the same problem, here is a solution. I only have on contact group, so it's no big problem to manage.

    once you are logged in you can get all your groups using the following method:

    groups = gd_client.GetGroupsFeed()
    

    and since I only have one, I can just pop it off like this:

    group = groups.entry.pop()
    

    now all I have to do is this:

    query = gdata.contacts.service.ContactsQuery()
    query.max_results = 1000
    query.group = group.id.text
    
    gd_feed = gd_client.GetContactsFeed(query.ToUri())
    

    enjoy