How to delete a Facebook comment post using the Facebook GRAPH API?

坚强是说给别人听的谎言 提交于 2020-01-11 04:05:08

问题


I started researching this because I wanted to be able to delete a comment on the wall of a Facebook Event, because the "Remove post" doesn't seem to be applicable to comments on an Event wall. However, since I don't know if it is even possible I decided to see if I could mannually delete a post I made to my own wall first since that is possible. Note I am NOT using any SDK; I am just building the URL and entering it in the address bar in Firefox v3.6.17.

These posts have helped me alot since I am now starting: Delete facebook post with Graph API - trouble getting this to work and Facebook SDK and Graph API Comment Deleting Error

I can see the comment data and all its field via the following:

https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]  
`where [POST_ID] and [ACCESS_TOKEN] were got using the graph API.`

However, where do I put the "method=delete" command in the URL? I tried putting it at the end, like

https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete 

but that results in a OAuthException stating "Invalid access token signature" because it seems to read the method as part of the access token.

I tried putting it after the post_id like

https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN] 

but that results in an Exception (Unsupported method) because it thinks "access_token=[ACCESS_TOKEN]" is part of the method being called.

I see one of the posts cited above states I have to prepend the userid to the object ID when deleting by using

DELETE https://graph.facebook.com/673509687_104812882909249?access_token={access_token} 
`where 673509687 is my userID and 104812882909249 is the objectID`  

But when I enter

DELETE https://graph.facebook.com/[POST_ID}?access_token=[ACCESS_TOKEN]

in the Firefox address bar it doesn't recognize it (I didn't think it would anyway) and uses it as a google search query.

How do I delete a comment if I have the comment_id and my access_token using the web browser?


回答1:


You have a big problem with your urls :

https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete

Should be :

https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN] & method=delete

Identically,

https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN]

should be :

https://graph.facebook.com/[POST_ID}?method=delete  & access_token=[ACCESS_TOKEN]

So you have to use the ? before entering your parameters and then & between each parameter and the order should not have any importance ..



来源:https://stackoverflow.com/questions/6008670/how-to-delete-a-facebook-comment-post-using-the-facebook-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!