干草,我正在从 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.";
}
}
但是该应用程序没有向我显示登录页面,因此我输入了它刚刚加载的真实帐户的用户名和密码,然后在文本框中显示“未登录”。