Windows Live Contacts API 获取电子邮件哈希值时出错 - JavaScript
以下代码用于 Window Live Contacts API 获取所有电子邮件地址。它在登录、注销和其他身份验证方面工作良好。我可以通过获取数据
函数调用收集登录用户的所有用户信息,但正在获取用户的电子邮件哈希值,其余电子邮件哈希值是空白的。我的通讯录中有 10 个电子邮件地址。
如何使用此 API 获取联系人的电子邮件地址?
<html>
<head>
<script src="https://js.live.net/v5.0/wl.js" type="text/javascript"></script>
</head>
<body>
<a href='javascript:void(0);' onclick='signUserIn();'>signUserIn</a> <br>
<a href='javascript:void(0);' onclick='signUserOut()'>signUserOut</a><br>
<a href='javascript:void(0);' onclick='loginStatus()'>Check User Status</a>
<a href='javascript:void(0);' onclick='getData()'>Get Data</a>
<script type="text/javascript" >
WL.init({
client_id: '0000000044444444',
redirect_uri: 'http://domain.com/contact.php',
response_type: "token",
logging: true
});
var scopesArr = ['wl.signin', 'wl.basic', 'wl.emails'];
function signUserIn() {
WL.login({ scope: scopesArr });
}
function loginStatus() {
WL.getLoginStatus(function(response) {
alert("response " + response );
});
}
function getData() {
alert( "getData");
WL.api(
{
path: "me/contacts",
method: "GET",
scope: scopesArr
},
function (result) {
if (!result.error) {
var resultData = result.data;
var emailHashes = new Array;
for (i = 0; i < resultData.length; i++) {
for (j = 0; j < resultData[i].email_hashes.length; j++) {
alert( "resultData " + resultData[i].email_hashes[j]);
emailHashes[emailHashes.length] = resultData[i].email_hashes[j];
}
}
var resultText = "";
for (k = 0; k < emailHashes.length; k++) {
resultText += emailHashes[k] + "\r\n";
}
// document.getElementById("emailHashes").setAttribute("rows", emailHashes.length);
document.getElementById("lists").value = resultText;
}
else {
alert("Error getting contacts: " + result.error.message);
}
});
}
function signUserOut() {
WL.logout();
}
</script>
<textarea rows="10" cols="100" id="lists"></textarea>
</body>
</html>
The following codes for the Window Live Contacts API to Get all email address from. Its works fine in login, log-out, and other authentications. I can collect all user information of logged in user with Get Data
function call, but am getting email hashes of users, rest of the email hashes are blank. I have 10 email address in my contact book.
How do i get the email addresses of my contacts using this api?
<html>
<head>
<script src="https://js.live.net/v5.0/wl.js" type="text/javascript"></script>
</head>
<body>
<a href='javascript:void(0);' onclick='signUserIn();'>signUserIn</a> <br>
<a href='javascript:void(0);' onclick='signUserOut()'>signUserOut</a><br>
<a href='javascript:void(0);' onclick='loginStatus()'>Check User Status</a>
<a href='javascript:void(0);' onclick='getData()'>Get Data</a>
<script type="text/javascript" >
WL.init({
client_id: '0000000044444444',
redirect_uri: 'http://domain.com/contact.php',
response_type: "token",
logging: true
});
var scopesArr = ['wl.signin', 'wl.basic', 'wl.emails'];
function signUserIn() {
WL.login({ scope: scopesArr });
}
function loginStatus() {
WL.getLoginStatus(function(response) {
alert("response " + response );
});
}
function getData() {
alert( "getData");
WL.api(
{
path: "me/contacts",
method: "GET",
scope: scopesArr
},
function (result) {
if (!result.error) {
var resultData = result.data;
var emailHashes = new Array;
for (i = 0; i < resultData.length; i++) {
for (j = 0; j < resultData[i].email_hashes.length; j++) {
alert( "resultData " + resultData[i].email_hashes[j]);
emailHashes[emailHashes.length] = resultData[i].email_hashes[j];
}
}
var resultText = "";
for (k = 0; k < emailHashes.length; k++) {
resultText += emailHashes[k] + "\r\n";
}
// document.getElementById("emailHashes").setAttribute("rows", emailHashes.length);
document.getElementById("lists").value = resultText;
}
else {
alert("Error getting contacts: " + result.error.message);
}
});
}
function signUserOut() {
WL.logout();
}
</script>
<textarea rows="10" cols="100" id="lists"></textarea>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,我找到了解决方案,您所需要做的就是将以下范围添加到您请求的范围列表中:“wl.contacts_emails”
之后,我必须从我的个人资料中删除我的应用程序重置所有范围并第二次添加我的应用程序。 (但是,如果您不想询问所有已经使用您的应用程序的人,我可以重置秘密令牌以强制用户再次添加您的应用程序)。
I had the same problem and I find the solution, all you need to do is add the following scope to your list of scopes you're requesting: "wl.contacts_emails"
After did that, I had to remove my application from my profile to reset all scope and add a second time my application. (But if you don't want to ask all people who alerady use your apps, I can just reset secret token to force user to add again your app).
Microsoft 不允许您通过 API 获取联系人电子邮件。他们仅发布用于匹配您端电子邮件的电子邮件哈希值。
很抱歉打扰你,但你运气不好。
我已经花了 5 天的时间尝试获取 Hotmail 联系人,但我无法弄清楚。
Microsoft does not allow you to get your contacts emails via API. They only issue email hashes used to match emails on your end.
Sorry to break it to you, but you are out of luck.
I have spent 5 days now trying to get Hotmail contacts and I can't figure it out.