private async void getFBUserDetails(FBUserRootobject fbuser) { string fb_id = fbuser.id; var role = RoleCombo.SelectedItem as RolesList; int role_id = role.Id; string name = fbuser.name; string email = fbuser.email; string salt = createSalt(6); string pass = generateSHA256Hash("fbuser", salt); string avatar = fbuser.picture.data.url; User new_user = new User { Fb_id = fb_id, Role_id = role_id, Name = name, Email = email, Password = pass, Salt = salt, Avatar = avatar }; bool exists = Database.checkIfFBUserExists(new_user.Fb_id); if (!exists) { addUser(new_user); } else { string message = "User is already registered!"; MessageDialog dialog = new MessageDialog(message); await dialog.ShowAsync(); } }
private async void getFBUserInfo() { FBSession clicnt = FBSession.ActiveSession; if (clicnt.LoggedIn) { var userId = clicnt.User.Id; string endpoint = "/" + userId + "?access_token=1819087251640431|n5eZecurPAfO37og6RphwZ04tb8&fields=id,name,email,picture"; PropertySet parameters = new PropertySet(); FBSingleValue value = new FBSingleValue(endpoint, parameters, FBUserRootobject.FromJson); FBResult graphResult = await value.GetAsync(); if (graphResult.Succeeded) { try { FBUserRootobject profile = graphResult.Object as FBUserRootobject; FBPicture.UserId = userId; getFBUserDetails(profile); } catch (Exception ex) { Debug.WriteLine(ex.ToString() + "\nBrak danych"); } } } }
public static FBUserRootobject FromJson(string jsonText) { FBUserRootobject profile = JsonConvert.DeserializeObject <FBUserRootobject>(jsonText); return(profile); }