0
Recently I had to import the Hotmail/Outlook mailing list of the users of my application, and I present below one of the ways you can proceed if you also need to implement this feature in your client-side system (Frontend) via Javascript.
0
Recently I had to import the Hotmail/Outlook mailing list of the users of my application, and I present below one of the ways you can proceed if you also need to implement this feature in your client-side system (Frontend) via Javascript.
0
Go to the page Microsoft Account Developer Center and create a new application by clicking on the "Create Application".
Enter the name and language you want to give to your app and click the button I Accept to indicate that you have read and agree to Microsoft’s terms of use for creating applications.
In Basic Information provide the other basic information of your application, such as the logo image and Urls of your application’s terms of service and usage policy.
On the tab API Settings, fill in the fields as follows:
Put the following code on your redirect page (in the case of the example, it would be the www.meusite.com.br/redirect.html page):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Página de Redirecionamento</title>
</head>
<body>
<!-- Este script irá repassar a resposta de autorização oauth para a página que fez a solicitação de obtenção da lista de contatos. -->
<script src="//js.live.net/v5.0/wl.js" type="text/javascript" language="javascript"></script>
</body>
</html>
Go to the tab App Settings to view the credentials ( Client ID and Client Secret) that your application should use to connect to the Windows Live API, which will be our next step.
Import the Windows Live library to the page where you want to import your user’s email contact list, as follows:
<script src="//js.live.net/v5.0/wl.js"></script>
Initialize the Live Javascript SDK by running the code below and overriding the values of client_id
and redirect_uri
with the values of your own application:
WL.init({
client_id: 'CLIENT_ID_DE_SEU_APLICATIVO',
redirect_uri: 'www.meusite.com.br/redirecionamento.html',
scope: ["wl.basic", "wl.contacts_emails"],
response_type: "token"
});
Create a button to import contacts:
<input type="button" onclick="importeContatosDoHotmail();" value="Importar Contatos" />
Implement the import function of Hotmail/Outlook contacts as in the following code:
function importeContatosDoHotmail() {
WL.login({
scope: ["wl.basic", "wl.contacts_emails"]
}).then(function (response) {
WL.api({
path: "me",
method: "GET"
}).then(function (responseMe) {
// Dados do perfil do usuário.
console.log(responseMe);
WL.api({
path: "me/contacts",
method: "GET"
}).then(function (responseMeContacts) {
// Lista de contatos de emails do usuário.
console.log(responseMeContacts.data);
},
function (responseFailed) {
// Motivo da falha de obtenção da lista de contatos do usuário.
console.log(responseFailed);
}
);
},
function (responseFailed) {
// Motivo da falha de obtenção dos dados do perfil do usuário.
console.log(responseFailed);
}
);
},
function (responseFailed) {
// Motivo da falha de autenticação com o Windows Live.
console.log(responseFailed);
});
}
Browser other questions tagged javascript email importing
You are not signed in. Login or sign up in order to post.