Import Hotmail Contacts using Javascript


Import Hotmail Contacts using Javascript
For more information visit
http://support.loginradius.com/hc/en-us/articles/201625646-How-do-I-create-a-MSN-Hotmail-Live-app-

Example:-
<!DOCTYPE html>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <!--WL Library For Hotmail API-->
        <script src="//js.live.net/v5.0/wl.js"></script>
</head>
<script>
    var APP_CLIENT_ID = "000000004812A421";
    var REDIRECT_URL = "http://xyz.com/index/import";
    var CLIENT_SECRET = "c86m2XYZXaIG9CjTsbpQdvbIuR7vaaDl";
    WL.init({
              client_id: APP_CLIENT_ID,
              client_secret:CLIENT_SECRET,
              redirect_uri: REDIRECT_URL,
              scope: "wl.signin",
              response_type: "token"
          });
   
   
    $(document).on("click",".logintohotmail", function(){
           window.setTimeout(checkHotmailAuth,3);
    });
   
          function checkHotmailAuth() {
        WL.login({
            scope: ["wl.signin", "wl.basic", "wl.contacts_emails"]
        }).then(
            function (response) {
                WL.api({
                    path: "me/contacts",
                    method: "GET"
                }).then(
                    function (response) {
                       
                        console.log(response);
                       
                        if(response.data.length > 0)
                          {
                            emailList = document.getElementById('Hotmailsemails');
                            for ( var i= 0 ; i < response.data.length ; i++)
                                  {
                                var resultData = response.data[i];
                                //console.log(resultData);
                                emailList.innerHTML += '<li class="list-group-item">' + resultData.first_name + ' '+resultData.last_name+'->'+resultData.emails.personal+ '</li>';
                               
                            }
                        }
                    },
                    function (responseFailed) {
                        document.getElementById("infoArea").innerText =
                            "Error calling API: " + responseFailed.error.message;
                    }
                );
            },
            function (responseFailed)
            {
                document.getElementById("infoArea").innerText =
                    "Error signing in: " + responseFailed.error_description;
            }
        );
    }
</script>                  
 <!--END: Hotmail Contatcs API-->
 <button id="ImportContact" class="logintohotmail">Login To Hotmail</button>
 <br>
 <ul id="Hotmailsemails" class="list-group"></ul>

Comments

Popular posts from this blog

Login with facebook using coldfusion

Create CSV file in Coldfusion Using CFFile

Get Previous One Day Data in Sql Server