Skip to content

Instantly share code, notes, and snippets.

@scvalex
Created July 15, 2010 23:25
Show Gist options
  • Save scvalex/477698 to your computer and use it in GitHub Desktop.
Save scvalex/477698 to your computer and use it in GitHub Desktop.

Revisions

  1. scvalex revised this gist Jul 15, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pull_contacts.py
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ def usage():
    gd_client.ProgrammaticLogin()

    query = gdata.contacts.service.ContactsQuery()
    query.max_results = 100
    query.max_results = 1000
    contacts = gd_client.GetContactsFeed(query.ToUri())
    printFeed(contacts)

  2. scvalex created this gist Jul 15, 2010.
    44 changes: 44 additions & 0 deletions pull_contacts.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/usr/bin/python

    """Module for pulling contacts out of Google and storing them to disk
    (or something).
    See the official guide for a more in-depth look at GData Python
    http://code.google.com/apis/contacts/docs/1.0/developers_guide_python.html
    """

    import atom
    import gdata.contacts
    import gdata.contacts.service
    import getpass
    import sys

    def printFeed(feed):
    for entry in feed.entry:
    nick = ""
    name = entry.title.text
    for email in entry.email:
    print('%s\t%s\t"%s" <%s>' % (nick, name, name, email.address))

    def main(args):
    def usage():
    print("""usage: pull_contacts.py <email>
    """)

    if len(args) < 1:
    usage()
    exit(1)

    gd_client = gdata.contacts.service.ContactsService()
    gd_client.email = args[0]
    gd_client.password = getpass.getpass()
    gd_client.source = "abstractbinary.org-pull_contacts-1"
    gd_client.ProgrammaticLogin()

    query = gdata.contacts.service.ContactsQuery()
    query.max_results = 100
    contacts = gd_client.GetContactsFeed(query.ToUri())
    printFeed(contacts)

    if __name__ == "__main__":
    main(sys.argv[1:])