导入hotmail联系人 [英] import hotmail contacts

查看:121
本文介绍了导入hotmail联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



我需要你帮助导入hotmail联系我写了下面的代码:


hello firends,

I need you help in importing hotmail contacts i have written the below code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WindowsLive;
using System.Net;
using System.Xml;
using System.IO;
using System.Web.Services;
public partial class Demo : System.Web.UI.Page
{

    const string Offers = "Contacts.View";
    const string AuthCookie = "delauthtoken";
    static WindowsLiveLogin wll = new WindowsLiveLogin(true);
    protected WindowsLiveLogin.ConsentToken Token;
    protected string ConsentUrl;
    protected void Page_Load(object sender, EventArgs e)
    {
        ConsentUrl = wll.GetConsentUrl(Offers);
        Session["wll"] = wll;
        if (Session["HotmailToken"] != null)
        {
            WindowsLiveLogin.ConsentToken token = wll.ProcessConsent(Request.Form);
            Token = wll.ProcessConsentToken((string)Session["HotmailToken"]);
            if (Token != null)
            {
                string lid = Token.LocationID;
                long llid = Int64.Parse(lid, System.Globalization.NumberStyles.HexNumber);
                string delegatedToken = Token.DelegationToken;
                string uri = "https://livecontacts.services.live.com/@L@" + lid + "/rest/LiveContacts/Contacts/";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
                request.UserAgent = "Windows Live Data Interactive SDK";
                request.ContentType = "application/xml; charset=utf-8";
                request.Method = "GET";
                request.Headers.Add("Authorization", "DelegatedToken dt=\"" + delegatedToken + "\"");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                XmlDocument contacts = new XmlDocument();
                contacts.LoadXml(new StreamReader(response.GetResponseStream()).ReadToEnd());
                List<string> emails = new List<string>();

                XmlNodeList nodeList = contacts.SelectNodes("//Email/Address");
                foreach (XmlNode node in nodeList)
                {
                    if (!String.IsNullOrEmpty(node.InnerText))
                    {
                        emails.Add(node.InnerText);
                    }
                }
                listView.DataSource = emails;
                listView.DataBind();

            }
        }
    }

    [WebMethod]
    public static string GetHotmailContacts()
    {
        return wll.GetConsentUrl(Offers);
    }
}




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WindowsLive;
namespace ImportContacts
{
    public partial class GetDateFromHotmail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            WindowsLiveLogin.ConsentToken token = ((WindowsLiveLogin)Session["wll"]).ProcessConsent(Request.Form);
            Session["HotmailToken"] = token.Token;
            Response.Redirect("http://pinny.com");

        }
    }
}







但我得到一个例外abc.com提出了一个不安全的请求来访问您的信息.Windows Live不允许与此类请求共享信息。





所以朋友们请帮助我。

提前提前

推荐答案

看一下这个帖子:



http://social.msdn.microsoft.com/Forums/en-AU/wliddev/thread/8a6ccf87-0131-476d-8328-7b78073d8336 [ ^ ]
Have a look at this thread:

http://social.msdn.microsoft.com/Forums/en-AU/wliddev/thread/8a6ccf87-0131-476d-8328-7b78073d8336[^]


请参阅:创建和阅读Hotmail联系人(Live Connect) [ ^ ] - 本主题介绍您的应用如何使用Live Connect API用于创建和阅读Hotmail用户的联系人



以下是我发现的一些测试在其中 [ ^ ];看看

1.注册您的应用程序以获取客户端ID和客户端密钥

http://go.microsoft.com/fwlink/?LinkID=144070 [ ^ ]

2.下载并安装Windows Live ID委托身份验证SDK 1.2

http://www.microsoft.com/download/en/details.aspx?id=2860 [ ^ ]

3.将文件windowsLiveLogin.cs添加到Project。它应该在

C:\Program Files \ Windows Live ID \ DelAuth \ App_Code
Please refer: Creating and reading Hotmail contacts (Live Connect)[^]- This topic describes how your apps can use the Live Connect APIs to create and read a Hotmail user's contacts.

Here are few test I found here[^] which you need to do before importing contacts from hotmail; have a look
1. Register your application to get Client ID and Client Secret
http://go.microsoft.com/fwlink/?LinkID=144070[^]
2. Download and install Windows Live ID Delegated Authentication SDK 1.2
http://www.microsoft.com/download/en/details.aspx?id=2860[^]
3. Add file windowsLiveLogin.cs to Project. It should be in
C:\Program Files\Windows Live ID\DelAuth\App_Code


这篇关于导入hotmail联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆