Import contacts from yahoo in python
Question: 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](http://pypi.python.org/pypi/ContactGrabber/0.1). I found
solutions, that require BBAuth Token in [django-friends
app](https://github.com/jtauber/django-friends).

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](https://github.com/tschellenbach/DjangoOpenInviter) for my
purposes.

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


Answer: The [Contacts REST
API](http://developer.yahoo.com/social/rest_api_guide/contacts-resource.html)
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']
    

