Removing a Facebook post from a page using $ facebook-> api

I am having trouble deleting a facebook message from my web application. Now I know the Facebook documentation and other SO posts that say to do this:

You can delete objects in the graph by issuing HTTP DELETE requests to the object URLs, ie, DELETE https://graph.facebook.com/ID?access_token=... HTTP/1.1 

But since Im is such a noob, I do not fully understand the short explanation of deletion using an HTTP request. Since this did not work when I tried, I assume that simply redirecting to the generated url in the above example does not delete anything. This means that there is a new area of ​​web development that I must now understand ... HTTP requests.

How is this done in php? php manual also does not help.


Additional Information:

I tried many different options:

 $facebook->api($post_url, 'DELETE', array('method'=> 'delete') ); 

The URL I'm passing is '/post_id' . post_id is fixed when mail is created and stored in the database. This identifier corresponds to $_GET['story_fbid'] , which can be found at any constant position. Perhaps this is not a valid identifier? I am returning an identifier with the following:

 //post to wall $postResult = $facebook->api($post_url, 'post', $msg_body ); //capture the id of the post $this->fb_post_id = $postResult['id']; 

When I run the code above, no errors occur. Touching it causes echo diagnostics after it starts.

These are the different string combinations that I passed the api with $post_url :

 /postid api returns true, nothing is deleted from Facebook /userid_postid api returns false, Error: (#100) Invalid parameter /postid_userid api returns false, Error: (#1705) : Selected wall post for deletion does not exist /accesstoken_postid api returns false, Error: (#803) Some of the aliases you requested do not exist /postid_accestoken api returns false, Error: (#803) Some of the aliases you requested do not exist 
+4
source share
5 answers

Updated answer:

Based on your comment "this is a page", I looked at the API chart page in detail. If I understand the details correctly, Delete is not supported for Page Recording . Each connection in detail (Events, messages, question, etc.) has a “Create” section, and if the connection supports “Delete”, it has a description of “Delete”. The Posts (to feed) section mentions Create, not Delete.

0
source

This should work:

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

will return a boolean value, true if it succeeded, and false if it failed.

Try adding the object identifier to the object identifier when deleting, for example:

 $facebook->api("/USER-ID_YOUR-POST-ID","DELETE"); 

as:

 $facebook->api("/12345132_5645465465454","DELETE"); //where 12345132 is fb userid and //5645465465454 is object id --> post id 
+4
source

I had a successful deletion of posts from a page using a page access token with read_stream and manage_pages permissions.

 try { $args = array( 'access_token' => $page_token ); $deleted = $facebook->api('/'.$post_id, 'DELETE', $args); } catch (FacebookApiException $e) { echo 'Delete review page wall error: ' . $e->getType() . ' ' . $e->getMessage(); } 
+1
source

You cannot “unpublish” a message, but this is not the same as deleting a message. Deleting a message is pretty simple.

You only need to get COMMENT_ID and post it on Facebook.

  $post_url = 'https://graph.facebook.com/'. $COMMENT_ID .'?access_token=' . $page_access_token . '&method=delete'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $post_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $return = curl_exec($ch); curl_close($ch); 

To clarify this: this works outside of the page APIs if you have rights to manage messages.

0
source

I was able to remove the message from the page using php SDK 5.4 using this

 $post = $fb->request('DELETE', '/'.$post_id,[], $page['accesstoken']) 
0
source

All Articles