Search code examples
pythondjangoyahooyahoo-api

Import contacts from yahoo in python


Is there are official way to import contacts from user address book from yahoo?

For google it's really simple as:

import gdata
contacts_service = gdata.contacts.service.ContactsService()
contacts_service.email = email
contacts_service.password = password
contacts_service.ProgrammaticLogin()
query = gdata.contacts.service.ContactsQuery()
query.max_results = GOOGLE_CONTACTS_MAX_RESULTS
entries = contacts_service.GetContactsFeed(query.ToUri())

Is there such simple way for yahoo?

I found some solutions, that don't use api and looks strange for serious game - for example ContactGrabber. I found solutions, that require BBAuth Token in django-friends app.

But, I want official, clear, way to grab user contacts from yahoo. Does it exists?

UPD: Finally I am avoiding use of yahoo api, and using django-openinviter for my purposes.

But I am still looking for examples of importing user contacts using api.


Solution

  • The Contacts REST API is pretty straight-forward. The URL that you're after is

    http://social.yahooapis.com/v1/user/{guid}/contacts.json
    

    Here is a script that will extract things for you. You can expand this to include authentication.

    import urllib2
    import json
    
    def get_contacts(guid):
        url = 'http://social.yahooapis.com/v1/user/{}/contacts.json'.format(guid)
        page = urllib2.urlopen(url)
        return json.load(page)['contacts']['contact']