Reputation: 1183
I have tried almost every variation I can think of but nothing seems to work. I am trying to simply delete a Facebook request (user-to-user or app-to-user request) using the delete method of the C# SDK or using the HTTPWebRequest method. I am grabbing the "request_ids" querystring parameter from the URL when a user clicks on a request and using that for the method along the Facebook User ID and the App Access Token, both of both of which are stored in session variables. Below are some of the variations have I tried (did not include a few) but none of these work for some reason. I am using ASP.NET 3.5 so the C# SDK I have is the ASP.NET 3.5 version (can't use dynamic types). Any help is appreciated!
Option #1
public static void deleteFbRequest(string facebookRequestId, string appAccessToken, string fbuserid)
{
var fb = new FacebookClient();
var url = "https://graph.facebook.com/" + fbuserid + "?access_token=" + appAccessToken;
fb.Delete((String.Format(url, facebookRequestId + "_" + fbuserid, fb.AccessToken)));
}
Option #2
public static void deleteFbRequest(string facebookRequestId, string appAccessToken, string fbuserid)
{
var fb = new FacebookClient();
var result = fb.Delete(facebookRequestId.ToString() + "_" + fbuserid.ToString());
}
Option #3
public static void deleteFbRequest(string facebookRequestId, string appAccessToken, string fbuserid)
{
var fb = new FacebookClient(appAccessToken);
var parameters = new Dictionary<string, object>();
parameters["access_token"] = appAccessToken;
parameters["method"] = "DELETE";
var result = fb.Delete("/" + facebookRequestId + "_" + fbuserid, parameters);
}
Option #4
public static void deleteFbRequest(string facebookRequestId, string appAccessToken, string fbuserid)
{
string url = "";
url = "https://graph.facebook.com/" + facebookRequestId + "_" + fbuserid + "?access_token=" + appAccessToken + "&method=DELETE";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Proxy = null;
}
Upvotes: 0
Views: 170
Reputation: 1183
OK, it's always the little things that cause bugs. After racking my brain for ours, the issue was the session variables I used for the method parameters had whitespace at the end of the them (extra spaces). So I used the trim method and it works (see below):
Session["FacebookUserID"].ToString().Trim()
Geez!!
Upvotes: 1