views:

365

answers:

3

Working with the Facebook php SDK's, I am having a lot of trouble figuring out how to delete comments, given its id and xid.

At first I was using the REST API, where you can call 'comments_remove($xid, $id);' to delete a comment. The problem with this method came when the xid parameter only accepts alphanumeric characters and underscores. Based on the documentation (http://developers.facebook.com/docs/reference/fbml/comments ) a valid XID can be the result of any url_encode.

Now I am testing my luck with the new GRAPH api. Looking at http://developers.facebook.com/docs/api under 'Deleting Objects', It seems that comment deleting is definitely supported. However, I have tried sending a DELETE request, and I have also tried sending POST and GET to the object url with the argument 'method=delete'.

No matter how I try it, I always get the same error:

{"error":{"type":"GraphMethodException","message":"Unsupported delete request."}}

I am sending the access token as a parameter as well. The access token that I am sending is the access token saved in the facebook cookie from the single sign on javascript cookie. These are all comments made on my application. Does this happen to anyone else, or am I simply not doing this right?

Any help or guidance is GREATLY appreciated.

A: 

Fixed!

You have to prepend the userid to the object ID when deleting:

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

James Hartig
A: 

Try with this:

FB.api('/'+_idComment, 'get', { method:'delete' }, function(response){ //Your code }

fsalf