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
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.