尝试登录Windows Phone 8.1 App时,Facebook ID的空值

时间:2015-04-19 20:40:45

标签: c# facebook windows-phone-8.1 facebook-login

我试图将Facebook登录与我的应用集成。我设法登录,获取配置文件名称,但不是配置文件图片。经过检查,我意识到它是由于facebookID中的空值。如何解决这个问题?

private void LoadUserInfo()
        {
            var UISyncContext = TaskScheduler.FromCurrentSynchronizationContext();
            FBSession fbSession = FBSession.Instance;
            var fb = new FacebookClient(fbSession.Token.AccessToken);

            fb.GetCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    Task.Factory.StartNew(() =>
                    {
                        Debug.WriteLine(e.Error.Message);
                    }, new System.Threading.CancellationToken(), TaskCreationOptions.PreferFairness, UISyncContext);
                    return;
                }

                var result = (IDictionary<string, object>)e.GetResultData();

                Task.Factory.StartNew(() =>
                {
                    TextBlock user_Name = FindChildControl<TextBlock>(homeSection, "user_Name") as TextBlock;
                    Image user_Image = FindChildControl<Image>(homeSection, "user_Image") as Image;
                    Debug.WriteLine("ID: " + fbSession.Token.AccessToken);
                    var profilePictureUrl = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", fbSession.Token.FacebookId, "square", fbSession.Token.AccessToken);
                    user_Image.Source = new BitmapImage(new Uri(profilePictureUrl));
                    user_Name.Text = String.Format("{0} {1}", (string)result["first_name"], (string)result["last_name"]);
                }, new System.Threading.CancellationToken(), TaskCreationOptions.PreferFairness, UISyncContext);
            };

            fb.GetTaskAsync("me");
        }

我做错了什么?如何解决这个问题?

0 个答案:

没有答案