Giter Club home page Giter Club logo

python-contact-importer's Introduction

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.

python-contact-importer's People

Contributors

millioner avatar mpcabd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.