幾乎所有的SNS網站都有[邀請站外好友]加入本站這個功能
這個功能的關鍵點在於取得用戶的已有聯系人列表
首先我想到的是參照已有網站的實現方式
開心網
開心網和校內網的實現方式大致相同
以上兩個網站的共同點是都要求用戶輸入MSN的用戶名和密碼
FaceBook的實現與以上兩個網站截然不同
用戶點擊[Find Friends]後
點擊[Sign In]後
綜合考慮
第一步
申請一個微軟雲計算的一個Project
ioning/Default
Application ID:
Domain(s):
Return URL:
Secret Key:
nazgnMZRWbbgaleiDpvUhG
第二步
下載 Windows Live ID Delegated Authentication SDK
其中有C#
第三步
安裝下載的文件到指定目錄內
第四步
在IIS中新建一個虛擬目錄
第五步
修改hosts文件
第六步
修改Sample
第七步
把Sample
其中Click Here中的URL是動態構造的
點擊Click Here就轉向Live網站進行登錄
WindowsLiveLogin
WindowsLiveLogin wll = new WindowsLiveLogin(true);
WindowsLiveLogin
第八步
取得MSN中的聯系人信息
微軟提供了允許我們通過REST方式訪問contracts服務
The Delegated Authentication token (DAT)
The Location ID (lid)
顯然
public string GetContacts(WindowsLiveLogin
string lid = ct
string delegatedToken = ct
// Construct the request URI
string uri =
HttpWebRequest request = (HttpWebRequest)WebRequest
request
request
request
// Add the delegation token to a request header
request
//Issue the HTTP GET request to Windows Live Contacts
HttpWebResponse response = (HttpWebResponse)request
//The response body is an XML stream
XmlDocument contacts = new XmlDocument();
contacts
//Use the document
return contacts
//Close the response
//response
}
我們可以針對返回的XML字符串進行分析
From:http://tw.wingwit.com/Article/program/net/201311/11677.html