Here is something interesting that i recently found out when i was working on my social media site, toolbox.my. I was trying to delete post that was sent out from this app but there wasn't any documentation written on it and after some investigation and testing i finally got it right!
Deleting User Post
Before i go into how group post is being deleted, if we look at facebook graph api, it stated under "Deleting" that
An app can delete a post if it published it
Which means that a post can only delete by the person who creates it. Therefore, if this is a post created by an app, only the app can deleted it although the user created it using the app. On the other hand, if the user create a post in app and tries to use the app to delete, it won't work.
Now, if we look at the php sample code from the graph api, its pretty straight forward.
/* make the API call */ $request = new FacebookRequest( $session, 'DELETE', '/{post-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); /* handle the result */
but but but, if it said there isn't such method (which usually will), this is most likely because you will also need to indicated who's post this is by doing this,
/* make the API call */ $request = new FacebookRequest( $session, 'DELETE', '/{user-id}_{post-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); /* handle the result */
and it should delete it properly
Deleting Group or Page Post
If you did read what i wrote on deleting user post, you might have guessed how this could apply to all other post created from other section. All you really need to do to delete group post is to do this
/* make the API call */ $request = new FacebookRequest( $session, 'DELETE', '/{group-id}_{post-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); /* handle the result */
while page post you would do this
/* make the API call */ $request = new FacebookRequest( $session, 'DELETE', '/{page-id}_{post-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); /* handle the result */
Basically its the same and the trick here is to tell the delete restful api that you are going to delete a particular object post and these object can be either user, page or groups.
Deleting Post Using Facebook api
In Summary, i would say if you are deleting using facebook api, make sure that the post that you are deleting is created by the app itself and not by the user and since you are using facebook graph api, it is most likely you are using an app to delete a post that was created by your facebook api. Just take note that you can only delete anything created by your app and you won't be able to delete any post by the user although the user is logged into your app (but the app is deleting the user post so it wont work).