2

我是 Live SDK 的新手,我正在尝试使用它连接到用户的个人资料并从中获取数据我已经阅读过它并使用以下代码登录到用户的帐户

private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
{
    if (e.Status == LiveConnectSessionStatus.Connected)
    {
        session = e.Session;
        client = new LiveConnectClient(session);
        try
        {
            LiveAuthClient auth = new LiveAuthClient(btnSignin.ClientId);
            //LiveLoginResult initializeResult = await auth.InitializeAsync();
            try
            {
                LiveLoginResult loginResult = await auth.LoginAsync(new string[] { "wl.basic" });
                if (loginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    LiveConnectClient connect = new LiveConnectClient(auth.Session);
                    LiveOperationResult operationResult = await connect.GetAsync("me");
                    dynamic result = operationResult.Result;
                    if (result != null)
                    {
                        this.infoTextBlock.Text = string.Join(" ", "Hello", result.name, "!");
                    }
                    else
                    {
                        this.infoTextBlock.Text = "Error getting name.";
                    }
                }
            }
            catch (LiveAuthException exception)
            {
                this.infoTextBlock.Text = "Error signing in: " + exception.Message;
            }
            catch (LiveConnectException exception)
            {
               MessageBox.Show("Error calling API: " + exception.Message);
            }
        }
        catch (LiveAuthException exception)
        {
            this.infoTextBlock.Text = "Error initializing: " + exception.Message;
        }

    }
    else
    {

        client = null;
    }
}

它登录我的模拟器和我的 2 个 lumia 620 设备之一,但使用另一个设备它给了我以下异常 **

*> {client_error: Microsoft.Live.LiveConnectException: 异常类型

引发了“Microsoft.Live.LiveConnectException”。在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 在 PhoneApp2.MainPage.d__6.MoveNext ()}*

**

4

0 回答 0