我正在构建一个Windows Phone 8应用程序,我想为用户提供Facebook登录。这段代码工作2天前,但是一个队友做了更改,现在它不再工作了。他不知道他改变了什么。
登录工作正常,但获取用户数据是个问题。 这是我获取用户信息的代码:
private async void GraphApi()
{
FacebookClient fbClient = new FacebookClient(AccessToken);
fbClient.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
Dispatcher.BeginInvoke(() =>
{
IAsyncResult message = Guide.BeginShowMessageBox(AppResources.ApplicationTitle, e.Error.Message, new string[] { AppResources.ButtonOk }, 0, MessageBoxIcon.Alert, null, null);
message.AsyncWaitHandle.WaitOne();
});
return;
}
IDictionary<string, object> result = (IDictionary<string, object>)e.GetResultData();
Dispatcher.BeginInvoke(() =>
{
AppSettings["Username"] = (string)result["name"];
AppSettings["FirstName"] = (string)result["first_name"];
AppSettings["LastName"] = (string)result["last_name"];
AppSettings.Save();
ProfileName.Text = "Hi " + (string)result["name"];
FirstName.Text = "First Name: " + (string)result["first_name"];
FirstName.Text = "Last Name: " + (string)result["last_name"];
});
};
await fbClient.GetTaskAsync("me");
}
让Facebook客户端正常运行,然后转到此代码:fbClient.GetCompleted += (o, e)
并跳过此并且不会出错。
知道为什么这段代码不起作用?