Saturday, January 15, 2022

[FIXED] Delete facebook post with Graph API - trouble getting this to work

Issue

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?


Solution

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

$facebook->api("/COMMENT_ID","DELETE");


Answered By - ifaour

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.