Windows Live SDK First App

Prerequisite:

1. you must create an application record for it by using the Live Connect application management site (https://manage.dev.live.com)

2. If you are creating a web application, you must specify the redirect domain so that the service knows where to return users after they sign in

Note: if you don't have domain, or you want to test at local, you can assign a virtual domain name to your localhost ( add "127.0.0.1www.yourdomain.com" to "hosts" file under C:\Windows\System32\drivers\etc). Don't use any real domain name like google.com or your own domain name if you have any. If you did so, you cannot access the original remote site. This is because, 127.0.0.1 is loopback address, anything with that address will never leave your computer. 


Create a testing page via JS:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WindowsLiveSDKLearning._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script src="https://js.live.net/v5.0/wl.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function () {
        WL.init({
            client_id: 'xxxxxxx',
            redirect_uri: '/WindowsLiveSDKLearning/Default.aspx',
            response_type: "token"
        });
    });

    var scopesArr = ["wl.signin", "wl.emails"];
    function signUserIn() {
        WL.login({ scope: scopesArr });
    }

    function signUserOut() {
        WL.logout();
    }

    function getUserInformation() {
        WL.api(
        {
            path: "me",
            method: "GET"
        },
        function (response) {
            if (!response.error) {
                strGreeting = "Hi, " + response.first_name + ", your email address is " + response.emails.account + "!"
                alert(strGreeting);
            }
            else {
                alert(response.error.message);
            }
        });
    }

    
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
    </p>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409"
            title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>

    <input type="button" id="signin" value="signin" name="signin" οnclick="signUserIn()"/>
    <input type="button" id="signOutButton" value="signout" οnclick="signUserOut()" />
    <input type="button" id="getUser" value="Get User Information" οnclick="getUserInformation()" />

</asp:Content>

OR

Create a testing page via .Net Code:

By using OAuth WRAP to acquire user consent and access data from a Windows Live service, your application follows these steps:

  1. Creating a verification code.
  2. Creating an access token request.
  3. Creating a refresh token request.
  4. Getting user data.

Reference

  1. Windows Live SDK JavaScript API:http://msdn.microsoft.com/en-us/library/hh243643.aspx
  2. Windows Live SDK Functionality: http://msdn.microsoft.com/en-us/library/hh243648.aspx#user

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值