Unable to remove event wall post via Facebook API, getting invalid ID error

I’m having trouble removing a post I created on my Facebook event page. When I create the post, everything works fine, but when I try to delete it using the returned ID, I get an error.

Here’s how I create the post:

$my_event = "123456789012345";

$post_data = array(
  'access_token' => $user_token,
  'message' => 'Sample message for testing',
  'name' => 'Post Title Here',
  'caption' => "This is the caption text"
);

$response = $fb_api->api($my_event."/feed", "POST", $post_data);

I get the ID from the response:

$retrieved_id = $response["id"];
// returns something like: 123456789012345_987654321098765
// format appears to be EVENTID_MESSAGEID

But when I attempt to delete it:

try {
  $fb_api->api($retrieved_id, "DELETE");
}
catch (FacebookApiException $ex) {
  $error_msg = $ex->getMessage();
  echo $error_msg;
}

I keep getting this error: (#100) Invalid post id

I’ve also tried different approaches:

$fb_api->api("/123456789012345_987654321098765/", "DELETE"); // still invalid
$fb_api->api("/987654321098765", "DELETE"); // unsupported request
$fb_api->api("/123456789012345/feed/987654321098765", "DELETE"); // unknown path

It’s frustrating that the API gives me an ID that doesn’t work for deletion. Has anyone successfully deleted event wall posts using the Facebook API?

Had this exact issue a few months ago with an event management system. Turns out it was a timing problem. Facebook’s API has a delay between creating a post and when you can actually delete it. I fixed it by adding a 2-3 second delay between creating and deleting the post. Also check your API version - older ones had weird quirks with event post deletions. Try a GET request to the post ID first to make sure it exists before you delete it. If the GET fails, the post probably hasn’t propagated through Facebook’s system yet.

This usually happens when your access token doesn’t have the right permissions or it’s expired. You need publish_actions permission (or pages_manage_posts for newer API versions) to delete posts. Also check if you’re using a user token vs. a page token - event posts sometimes need page-level permissions. I had the same problem and regenerating the access token with explicit delete permissions fixed it. Your ID format looks right, so it’s probably a permission issue.

had the same issue too! just use the post id after the underscore, not the whole thing. and make sure your access token has publish_actions permission, it’s a must for deletion to work.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.