// save my facebook feed to local db. private void UpdateProfile(string Name, string FbId, string Picture) { using (DbStorage fbdb = new DbStorage(MainPage.strConnectionString)) { IQueryable<Db> fbQuery = from db in fbdb.user where db.AccessToken == _accessToken select db; Db ac = fbQuery.FirstOrDefault(); if (ac != null) { ac.Name = Name; ac.FbId = FbId; ac.Picture = Picture; fbdb.SubmitChanges(); } } }
/// <summary> /// Get access token from facebook and save to local database. /// </summary> void webBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { FacebookOAuthResult result; //Try because there might be cases when user input wrong password if (FacebookOAuthResult.TryParse(e.Uri.AbsoluteUri, out result)) { if (result.IsSuccess) { _accessToken = result.AccessToken; //AccessToken is used when you want to use API as a user //This example is not using it at all just showing it in a messagebox //Adding data to the local database using (DbStorage fbdb = new DbStorage(strConnectionString)) { IQueryable<Db> fbQuery = from db in fbdb.user select db; Db ac = fbQuery.FirstOrDefault(); if (ac == null) { Db newUser = new Db { AccessToken = _accessToken, }; fbdb.user.InsertOnSubmit(newUser); fbdb.SubmitChanges(); } } //Hide the browser controller _webBrowser.Visibility = System.Windows.Visibility.Collapsed; ContentPanel.Children.Remove(_webBrowser); SystemTray.SetProgressIndicator(this, indicator); Util myProfile = new Util(_accessToken); myProfile.myProfile(); // load friend list from App42 GetFacebookFriendsFromSocial(_accessToken); } else { var errorDescription = result.ErrorDescription; var errorReason = result.ErrorReason; MessageBox.Show(errorReason + " " + errorDescription); } } }
/// <summary> /// Get access token from facebook and save to local database. /// </summary> void WebBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { FacebookOAuthResult oauthResult; if (!_fb.TryParseOAuthCallbackUrl(e.Uri, out oauthResult)) { MessageBox.Show("tt"); return; } if (oauthResult.IsSuccess) { var accessToken1 = oauthResult.AccessToken; MessageBox.Show(accessToken1); _accessToken = oauthResult.AccessToken; //AccessToken is used when you want to use API as a user //This example is not using it at all just showing it in a messagebox //Adding data to the local database using (DbStorage fbdb = new DbStorage(strConnectionString)) { IQueryable<Db> fbQuery = from db in fbdb.user select db; Db ac = fbQuery.FirstOrDefault(); if (ac == null) { Db newUser = new Db { AccessToken = _accessToken, }; fbdb.user.InsertOnSubmit(newUser); fbdb.SubmitChanges(); } } //Hide the browser controller _webBrowser.Visibility = System.Windows.Visibility.Collapsed; ContentPanel.Children.Remove(_webBrowser); SystemTray.SetProgressIndicator(this, indicator); Util myProfile = new Util(_accessToken); myProfile.MyProfile(); // load friend list from App42 GetFacebookFriendsFromSocial(_accessToken); } else { // user cancelled MessageBox.Show(oauthResult.ErrorDescription); } }