0

干草,我正在从 windows phone 8 学习实时 SDK,并且我正在使用 Live SDK 5.5。我已经下载了 SDK,安装了它并在我的项目中引用了它我还为我的应用程序创建了一个密钥,我在这里遵循了确切的代码, 这就是我的代码:XAML

    <live:SignInButton ClientId="my ID" x:Name="btnSignin" Scopes="wl.signin wl.basic" Branding="Skydrive" SessionChanged="btnSignin_SessionChanged" Margin="10,0,-10,194" Height="104" VerticalAlignment="Bottom"  />
    <TextBlock Height="102" Foreground="White" HorizontalAlignment="Left" Margin="26,128,0,0" Name="infoTextBlock" VerticalAlignment="Top" Width="419" />
</Grid>

那是我的 C# 代码

    private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
    {
        if (e.Status == LiveConnectSessionStatus.Connected)
        {
            client = new LiveConnectClient(e.Session);
            LiveOperationResult operationResult = await client.GetAsync("me");
            try
            {
                dynamic meResult = operationResult.Result;
                if (meResult.first_name != null &&
                    meResult.last_name != null)
                {
                    infoTextBlock.Text = "Hello " +
                        meResult.first_name + " " +
                        meResult.last_name + "!";
                }
                else
                {
                    infoTextBlock.Text = "Hello, signed-in user!";
                }
            }
            catch (LiveConnectException exception)
            {
                this.infoTextBlock.Text = "Error calling API: " +
                    exception.Message;
            }
        }
        else
        {
            infoTextBlock.Text = "Not signed in.";
        }
    }

但是该应用程序没有向我显示登录页面,因此我输入了它刚刚加载的真实帐户的用户名和密码,然后在文本框中显示“未登录”。

4

1 回答 1

0

事实证明,在检查添加wl.skydrive到 Scopes 属性的评论后解决了这个问题:

<live:SignInButton ClientId="my ID" x:Name="btnSignin" Scopes="wl.signin wl.basic wl.skydrive" 
 Branding="Skydrive" SessionChanged="btnSignin_SessionChanged" Margin="10,0,-10,194"
 Height="104" VerticalAlignment="Bottom"/>

您可以在 MSDN 上阅读有关可用范围的更多信息。

此外,您的应用程序应该在您的帐户中标记为用于移动设备

于 2014-04-01T08:17:17.953 回答