Nikolay Fominyh
Nikolay Fominyh

Reputation: 9246

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.

Upvotes: 1

Views: 1421

Answers (2)

Tim McNamara
Tim McNamara

Reputation: 18385

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']

Upvotes: 4

obsoleter
obsoleter

Reputation: 355

Yahoo has some decent documentation on how to access its APIs with Python here. The information there will tell you how to access Yahoo APIs by YQL with http requests. This means directly performing the http GETs and POSTs and parsing the results yourself. However, they also have a python library that wraps those calls here, but it has not been updated since 10/13/2009, so your mileage may vary.

Upvotes: 2

Related Questions