void RemoveHiFromWall() { if (isLoggedIn) { if (string.IsNullOrEmpty(lastMessageId)) { new UIAlertView("Error", "Please Post \"Hi\" to your wall first", null, "Ok", null).Show(); return; } _fb.DeleteTaskAsync(lastMessageId).ContinueWith(t => { if (!t.IsFaulted) { if (t.Exception != null) { new UIAlertView("Couldn't Load Info", "Reason: " + t.Exception.Message, null, "Ok", null).Show(); return; } BeginInvokeOnMainThread(() => { new UIAlertView("Success", "You have deleted \"Hi\" from you wall.", null, "Ok", null).Show(); }); lastMessageId = null; } }); } else { new UIAlertView("Not Logged In", "Please Log In First", null, "Ok", null).Show(); } }
void HandleRemoveHiFromWall(object sender, EventArgs e) { if (isLoggedIn) { if (string.IsNullOrEmpty(lastMessageId)) { Alert("Error", "Please Post \"Hi\" to your wall first", false, (res) => {}); return; } fb.DeleteTaskAsync(lastMessageId).ContinueWith(t => { if (!t.IsFaulted) { RunOnUiThread(() => { Alert("Success", "You have deleted \"Hi\" from you wall.", false, (res) => {}); }); lastMessageId = null; } }); } else { Alert("Not Logged In", "Please Log In First", false, (res) => { }); } }
public async Task UnSubscribeApp(string pageId, string pageToken) { FacebookClient client = new FacebookClient(); try { await client.DeleteTaskAsync($"https://graph.facebook.com/v2.9/{pageId}/subscribed_apps?access_token={pageToken}"); } catch (FacebookOAuthException ex) { throw SocialExceptions.FacebookOauthException(ex); } }
private async void DeleteLastMessage_Click(object sender, RoutedEventArgs e) { btnDeleteLastMessage.IsEnabled = false; try { await _fb.DeleteTaskAsync(_lastMessageId); //MessageBox.Show("Message deleted successfully"); btnDeleteLastMessage.IsEnabled = false; } catch (FacebookApiException ex) { // handle error message } }
private async void btnDeleteLastMessage_Click(object sender, EventArgs e) { btnDeleteLastMessage.Enabled = false; try { await _fb.DeleteTaskAsync(_lastMessageId); MessageBox.Show("Message deleted successfully"); btnDeleteLastMessage.Enabled = false; } catch (FacebookApiException ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// For platforms that do not support dynamic cast it to either IDictionary<string, object> if json object or IList<object> if array. /// For primitive types cast it to bool, string, dobule or long depending on the type. /// Reference: http://facebooksdk.net/docs/making-asynchronous-requests/#1 /// </summary> public static void API( string endpoint, HttpMethod method, FacebookDelegate callback, object parameters = null) { #if NETFX_CORE Task.Run(async() => { FacebookClient fb = new FacebookClient(_fbSessionClient.CurrentAccessTokenData.AccessToken); FBResult fbResult = null; try { object apiCall; if (method == HttpMethod.GET) { apiCall = await fb.GetTaskAsync(endpoint, parameters); } else if (method == HttpMethod.POST) { apiCall = await fb.PostTaskAsync(endpoint, parameters); } else { apiCall = await fb.DeleteTaskAsync(endpoint); } if (apiCall != null) { fbResult = new FBResult(); fbResult.Text = apiCall.ToString(); fbResult.Json = apiCall as JsonObject; } } catch (Exception ex) { fbResult = new FBResult(); fbResult.Error = ex.Message; } if (callback != null) { Dispatcher.InvokeOnAppThread(() => { callback(fbResult); }); } }); #else throw new PlatformNotSupportedException(""); #endif }
private void DeleteLastMessage_Click(object sender, RoutedEventArgs e) { btnDeleteLastMessage.IsEnabled = false; _fb.DeleteTaskAsync(_lastMessageId).ContinueWith( t => { if (t.IsFaulted) { MessageBox.Show(t.Exception.GetBaseException().Message); return; } MessageBox.Show("Message deleted successfully"); btnDeleteLastMessage.IsEnabled = false; }, _ui); }
//public async Task<ActionResult> FB_AdminPages() //{ // var access_token = Convert.ToString(HttpContext.Items["access_token"]); // if (access_token != null) // { // var appsecret_proof = access_token.generateAppSecretProof(); // var fb = new FacebookClient(access_token); // dynamic myPages = await fb.GetTaskAsync("me/accounts?fields=id, name, link, is_published, likes, talking_about_count".GraphAPICall(appsecret_proof)); // var pageList = new List<FacebookPageViewModel>(); // foreach (dynamic page in myPages.data) // { // pageList.Add(DynamicExtention.ToStatic<FacebookPageViewModel>(page)); // } // return PartialView(pageList); // } // else // throw new HttpException(404, "missing access token"); //} #region test exceptions public async Task <ActionResult> FB_RevokeAccessToken() { var access_token = HttpContext.Items["access_token"].ToString(); if (!string.IsNullOrEmpty(access_token)) { var appsecret_proof = access_token.generateAppSecretProof(); var fb = new FacebookClient(access_token); dynamic myFeed = await fb.DeleteTaskAsync( "me/permissions".GraphAPICall(appsecret_proof)); return(RedirectToAction("Index", "Home")); } else { throw new HttpException(404, "Missing Access Token"); } }
public async void UnlinkFaceBook() { if (!HasConnection || UserPreference.AccessKey == null) { return; } var fb = new FacebookClient(UserPreference.AccessKey) { AppId = AppId }; await fb.DeleteTaskAsync(string.Format("https://graph.facebook.com/{0}/permissions", UserPreference.FbUserId)); UserPreference.AccessKey = null; UserPreference.FbUserId = null; UserPreference.Name = null; SaveSettings(); NotifyPropertyChanged("AccessKey"); }
private async void button2_Click(object sender, EventArgs e) { for (int i = 0; i < Groups.Count; i++) { if (GroupCb.GetItemChecked(i)) { //Get the user posts from the selected group var desired_posts = Posts.Where((p) => p.FkGroup == Groups[i].GroupID).ToList(); //Delete the user posts for (int j = 0; j < desired_posts.Count(); j++) { toolStripStatusLabel1.Text = "Deleting Post From Group: " + Groups[i].Groupname; await fb.DeleteTaskAsync(desired_posts[i].PostID); } } } toolStripStatusLabel1.Text = "Ready"; }
public async Task <JsonResult> Delete(string subscription_to_delete) { #region Facebook Graph API Retrieve Subscriptions var app_token = GetAppToken; if (!string.IsNullOrEmpty(app_token)) { var fb = new FacebookClient(app_token); #region Delete Subscription dynamic result = await fb.DeleteTaskAsync( string.Format("subscriptions?object={0}", subscription_to_delete)); #endregion return(Json(result)); } else { throw new HttpException(404, "Missing App Token"); } #endregion }
public async Task <JsonResult> DeletePhoto(string PhotoId) { var access_token = HttpContext.Items["access_token"].ToString(); if (!string.IsNullOrEmpty(access_token)) { var appsecret_proof = access_token.GenerateAppSecretProof(); var fb = new FacebookClient(access_token); #region Delete Photo dynamic result = await fb.DeleteTaskAsync( string.Format("/{0}", PhotoId) .GraphAPICall(appsecret_proof)); return(Json(result)); #endregion } else { throw new HttpException(404, "Missing Access Token"); } }
public static void API( string endpoint, HttpMethod method, FacebookDelegate callback, object parameters = null) { #if NETFX_CORE if (_web == null) { throw new MissingPlatformException(); } if (!IsLoggedIn) { // Already in use if (callback != null) { callback(new FBResult() { Error = "Not logged in" }); } return; } Task.Run(async() => { FBResult fbResult = null; try { object apiCall; if (method == HttpMethod.GET) { apiCall = await _client.GetTaskAsync(endpoint, parameters); } else if (method == HttpMethod.POST) { apiCall = await _client.PostTaskAsync(endpoint, parameters); } else { apiCall = await _client.DeleteTaskAsync(endpoint); } if (apiCall != null) { fbResult = new FBResult(); fbResult.Text = apiCall.ToString(); fbResult.Json = apiCall as JsonObject; } } catch (Exception ex) { fbResult = new FBResult(); fbResult.Error = ex.Message; } if (callback != null) { Dispatcher.InvokeOnAppThread(() => { callback(fbResult); }); } }); #else throw new PlatformNotSupportedException(""); #endif }