简体   繁体   中英

how to delete all facebook app request in rails?

I have a simple problem. I want to delete all app request sent via my Facebook application. Facebook documentation gives following code to do that:

DELETE https://graph.facebook.com/[<request_id>_<user_id>]?access_token=[USER or APP ACCESS TOKEN]

My problem is how to make HTTP DELETE request in my rails application? I am using following code to make HTTP GET request:

client = HTTPClient.new
@data = client.get_content(URI.parse(
  URI.encode("https://graph.facebook.com/RequestID?access_token=AccessToken")
))

Have a look at HTTPClient#delete method. I believe that's all you need. That should be smth like

client = HTTPClient.new
url = "https://graph.facebook.com/#{request_id}?access_token=#{access_token}"
data = client.delete url

Btw, why do you need that URI.parse and URI.encode stuff in you example?

And as you're dealing with Facebook I'd suggest looking at rest-graph gem. It's a pretty good tool for dealing with Facebook Graph API.

If the above doesn't work you can also GET the url, but specify the method as delete:

"https://graph.facebook.com/[<req id>]?access_token=[<access_token>]&method=delete"

This works for GET, POST, and DELETE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM