Reputation: 425
I am trying to delete pending app requests after entering my canvas application. I followed the instructions at https://developers.facebook.com/docs/requests/#deleting to issue an HTTP DELETE request to the URI mentioned in the documentation, using the request ID for a request from my app (accessed from the Graph API) as well as the user access token. I only get an error that says, "Some of the aliases you requested do not exist." I suspect there is an issue with my way of formatting this URI. Here's what I did, using Ruby on Rails and HTTParty:
HTTParty.delete("https://graph.facebook.com/#{outstanding_app_request_ids}?access_token=[#{session[:access_token]}]")
Does anyone have an example of a URI that successfully deletes these requests?
Upvotes: 1
Views: 1142
Reputation: 31
Using Koala is easiest in Ruby in my opinion:
@graph = Koala::Facebook.API.new(ACCESS_TOKEN) #Get access to graph
app_requests = @graph.get_connections(UID, 'apprequests') #Get app_requests
app_requests.collect {|request| request['id']}.each do |id|
@graph.delete_object(id) # Delete app_request
end
Upvotes: 3
Reputation: 1289
Open this url:
https://graph.facebook.com/{outstandingapprequestids}_{userid}?access_token=ACCESS_TOKEN&method=DELETE
Upvotes: 1
Reputation: 425
I have found a much more elegant solution that uses the Koala gem, and deletes the outstanding app requests in one swoop with a batch request. Here is the code that gets the requests, as well as deletes them all at once.
@graph = Koala::Facebook::API.new(ACCESS_TOKEN)
raw_requests = @graph.get_connections("me", "apprequests")
app_request_ids = []
raw_requests.each do |request|
app_request_ids << request["id"]
end
if app_request_ids.size > 0
@graph.batch do |batch_api|
app_request_ids.each do |app_request_id|
batch_api.delete_object(app_request_id)
end
end
end
Upvotes: 2