使用live sdk的LiveConnectException

时间:2014-04-04 01:49:59

标签: c# windows-phone-8 live-sdk

我是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设备之一,但是使用另一个设备它会给我以下例外 **

* GT; {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()} *

**

0 个答案:

没有答案