Revision: 20861
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 27, 2009 23:36 by PhilK
Initial Code
import sha import atom import gdata.contacts import gdata.contacts.service gd_client = gdata.contacts.service.ContactsService() # Change this obviously gd_client.email = 'EMAIL' gd_client.password = 'PASSWORD' gd_client.ProgrammaticLogin() """ This is used like a case statement later on. It's apparently a slightly slow way to do it but it just seems so elegant to me. I'm not a Pythonista at all though so there may be a more Pythonic way to do it that I'm not aware of. """ rel_list = {gdata.contacts.REL_WORK: "Work", gdata.contacts.REL_HOME: "Home", gdata.contacts.REL_OTHER: "Other", gdata.contacts.PHONE_MOBILE: "Mobile"} # This is the date used for "updated_min" below. date = '2009-08-12T00:00:00' query = gdata.contacts.service.ContactsQuery() query.updated_min = date feed = gd_client.GetContactsFeed(query.ToUri()) for contact in feed.entry: print contact.title.text for phone in contact.phone_number: print rel_list[phone.rel] + ": " + phone.text def rel_type(rel): pass
Initial URL
Initial Description
Simple example of using Google's API for contacts to display the contact name and phone number. More info in the comments.
Initial Title
GData Contacts Example
Initial Tags
google, python
Initial Language
Python