The Techjoomla Blog

Stay updated with all the latest happenings at Techjoomla. From news about the developments in your favourite extensions to Tips & Tricks about the Joomla CMS, Framework & Development.
Font size: +
1 minute reading time (291 words)

How to use Hotmail REST API to import contacts

How-to-use-Hotmail-REST-API-to-import-contacts

Importing contacts using Hotmail API works in three steps:
1. Getting Request Token:

Use the following URL to request token form Hotmail.

 https://login.live.com/oauth20_authorize.srf?client_id=CLIENT_ID&scope=wl.signin+wl.basic+wl.contacts_emails&response_type=code&redirect_uri=REDIRECT_URL
  • client_id(represented here by CLIENT_ID) is the one that you received when you registered your app in the Live Connect app management site.
  • scope parameter has to be "wl.signin+wl.basic+wl.contacts_emails" in case of Importing Email contacts
  • response_type parameter is set to code, which requests an authorization code.
  • redirect_uri parameter (represented here by REDIRECT_URL) is the URL that Live Connect returns users to after they sign in. 

2. Getting access token:

After the user successfully signs in and consents to the requested scopes, the Live Connect authorization web service uses the value of the redirect Uniform Resource Identifier (URI) to return the user to your site, and gives your app an authorization code as represented here by the string of characters that follow ?code=.

You can now use this authorization code to obtain an access token—the unique string of characters that allows your app to get a user's info from a service that is compatible with Live Connect. To request an access token, your app must include its client ID, a redirect URI, its client secret, the authorization code, and the grant_type parameter set to authorization_code, like this.

POST https://login.live.com/oauth20_token.srf
Content-type: application/x-www-form-urlencoded
client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&client_secret=CLIENT_SECRET&code=AUTHORIZATION_CODE&grant_type=authorization_code 

3. Getting Contacts:

Use the following URL to request token form Hotmail.

https://apis.live.net/v5.0/me/contacts?access_token=YOUR_ACCESS_TOKEN;

With this you will get the data in following format. 

{

"data": [

{

"id": "contact.ece6f2d6000000000000000000000000",

"first_name": "ABC",

"last_name": "XYZ",

"name": "ABC XYZ",

"is_friend": false,

"is_favorite": false,

"user_id": null,

"email_hashes": [

"3946bf036c5fd2b437bb5f3a9304f3449d0ce9ed882a0aeb9e55eeb814814763"

],

"updated_time": "2013-09-02T07:16:22+0000",

"emails": {

"preferred": "[email protected]",

"account": null,

"personal": "[email protected]",

"business": null,

"other": null

}

}

]

}

Here required emails are present along with email_hashes which you can easily use for sending mails.

10
×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Invitex 2.7.4 released
Quick2Cart 2.0.1 version released

Related Posts

 

Blog Topics