8

I'm using the following to post a message on my Facebook page:

$attachment =  array(
    'access_token' => $access_token,
    'message' => 'This is a test Message 4:',   
    'name' => "This is a test Name 4",
    'link' => "http://slashdot.org/",
    'description' => "This is a test Description 4"
);

$ret_code=$facebook->api('/me/feed', 'POST', $attachment);

This works great.

How do I delete the same post using the facebook GRAPH api? I read the docs and it says to issue a POST like:

https://graph.facebook.com/COMMENT_ID?method=delete

To test I set this up in a simple form with submit button, POSTing the data to https://graph.facebook.com/COMMENT_ID?method=delete (substituting COMMENT_ID fro the 11111111111_111111111111 id returned from the original publish call. This returns "This API call requires a valid app_id".

What is the correct way to issue a DELETE command?

ifaour
  • 38,035
  • 12
  • 72
  • 79
a coder
  • 7,530
  • 20
  • 84
  • 131

4 Answers4

11

Since you are using the php-sdk you just issue this call:

$facebook->api("/COMMENT_ID","DELETE");
ifaour
  • 38,035
  • 12
  • 72
  • 79
2

You can use the following code:

Http::post('https://graph.facebook.com/'.$fb_action_id, array('method'=>'delete', 'access_token'=>$your_app_access_token));

This post will return a boolean value, true if successed and false if failed.

j0k
  • 22,600
  • 28
  • 79
  • 90
Mohammad Anini
  • 5,073
  • 4
  • 35
  • 46
1

Its been discussed here Facebook SDK and Graph API Comment Deleting Error

Community
  • 1
  • 1
Inam Abbas
  • 1,480
  • 14
  • 28
0

you need to pass the access token too. You can delete all the milestones of a page like follows:

$milestones = $facebook->api('/PAGE_ID/milestones');
foreach($milestones[data] as $milestone)
{
  echo $milestone['id'];
  $args = array(
    'access_token'  => $pages_access_token
  );
  $deleted = $facebook->api($milestone['id'],"delete",$args);
  if($deleted)
  {
    echo " <font color=\"green\">OK</font><br>";
  }
  else
  {
    echo " <font color=\"red\">ERR</font><br>";
  }
}
mustafa
  • 3,605
  • 7
  • 34
  • 56