Skip to content

millioner/Python-contact-importer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python contact importer

Allows to export user contacts from Google, Yahoo! and Hotmail. Uses OAuth protocol for working with Google and Yahoo!. And Microsoft's "Delegated authentification" for Hotmail.

Requires:

Google contact export:

For using a Google contact export via OAuth protocol you need "consumer_key" and "consumer_secret" keys generated by Google for you domain. You can register your domain and get those keys here: https://www.google.com/accounts/ManageDomains

Yahoo!:

Also "consumer_key" and "consumer_secret" keys needed. App creating link: https://developer.apps.yahoo.com/dashboard/createKey.html

Windows Live

For hotmail contact export we need Client ID and Secret key. Detail app creating doc - http://msdn.microsoft.com/en-us/library/cc287659.aspx Application creating - https://manage.dev.live.com/Applications/Index

Settings example:

CONTACT_IMPORT_SETTINGS = {
    'google': { 'consumer_key': 'example.com', 'consumer_secret': 'bYG3xo_b-4cP7Yre1leF9Qsn' },
    'yahoo': {
        'consumer_key': 'dj0yJmk9ekN2dKHGgyZNjZWJmQ9WVdrOe9Fb3hhbTFXTkdrbWNHbzlNVGd5TXpNMU5ESTJNLJNKJDnsjdktXxpxNyZXQmeD1mZA--',
        'consumer_secret': '8712039132519876cdsv78dv9b04d29afb9'
    },
    'hotmail': {
        'consumer_key': '0004503076062AD7',
        'consumer_secret': '1AbHKgvjHu9Hi6RKg4mCeWybmNqCUE2',
        'policy_url': 'http://example.com/terms/'
    }
}

Usage (with Django):

urls.py:

# ...
urlpatterns = patterns('',
    # ...
    url(r'^contact-import/$', 'views.import_contacts', name='import_contacts'),
    # ...
)

views.py:

from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.decorators import login_required

from contact_importer.decorators import get_contacts

@csrf_exempt # Windows Live returns POST request
@login_required
@get_contacts
def import_contacts(request, contact_provider):
    contacts = contact_provider.get_contact_list()
    return render_to_response('contact_list.html', {
        'contacts': contacts,
    }, context_instance=RequestContext(request))

contact_list.html:

{% extends "base.html" %}

{% block content %}
    <ul>
        {% for contact in contacts %}
            <li>{{ contact.name }} - {{ contact.emails }}</li>
        {% endfor %}
    </ul>
{% endblock %}

Important!

Each your request to import_contacts should has a GET param "service"

For example if you want to get contacts from Google your request should be http://example.com/import_contacts?service=google

For Yahoo!: http://example.com/import_contacts?service=yahoo

And Hotmail: http://example.com/import_contacts?service=hotmail

First of all user will be redirected to the contact provider page, after approving he will be back to the site and his contacts will be imported.

That's it! More detail docs will be here soon.

About

Allow to import user contacts from Google, Yahoo! and Hotmail

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages