Created
February 7, 2014 04:11
-
-
Save eternaltung/8857280 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Microsoft.Live; | |
using Windows.UI.Popups; | |
namespace LiveSDKSample | |
{ | |
public sealed partial class MainPage : Page | |
{ | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
} | |
private async void LoginButton_Click(object sender, RoutedEventArgs e) | |
{ | |
try | |
{ | |
LiveAuthClient auth = new LiveAuthClient(); | |
//要求自動登入與讀取基本資訊兩種權限 | |
LiveLoginResult loginresult = await auth.LoginAsync(new string[] | |
{ | |
"wl.signin", | |
"wl.basic" | |
}); | |
if (loginresult.Status == LiveConnectSessionStatus.Connected) | |
{ | |
LiveConnectClient liveClient = new LiveConnectClient(loginresult.Session); | |
LiveOperationResult operationresult = await liveClient.GetAsync("me"); | |
//顯示登入帳號的姓名 | |
MessageDialog msg = new MessageDialog(string.Format("Name:{0}", | |
operationresult.Result["name"] | |
)); | |
await msg.ShowAsync(); | |
} | |
} | |
catch (LiveAuthException ex) | |
{ | |
MessageDialog msg = new MessageDialog(ex.Message); | |
msg.ShowAsync(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment