I'm trying to integrate Facebook Login with my app. I've managed to log in, get the Profile Name, but not the Profile Picture. Upon inspection I realized it's due to null value in facebookID. How to fix this?
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("http://ift.tt/1qxNyGU}", 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");
}
What am I doing wrong? How to fix this?
Aucun commentaire:
Enregistrer un commentaire