开发者

Deleting Wall Posts with Graph

开发者 https://www.devze.com 2023-04-13 06:42 出处:网络
I attempted to delete a wall post on a fan page using Graph.This appears to work fine for some posts, but for other posts, I get an Oath Exception (#200 Permissions Error).The posts I tested with were

I attempted to delete a wall post on a fan page using Graph. This appears to work fine for some posts, but for other posts, I get an Oath Exception (#200 Permissions Error). The posts I tested with were non-admins and the posts were made from facebook (not a 3rd part app). My app has publish_stream permissions. Any ideas? I am trying to build a page modera开发者_运维知识库tion tool for my client.


I have had success deleting posts on a fan page that were posted by non-admins using the page access token with manage_pages, publish_actions, and read_stream permissions. You may need to get an extended access token with setExtendedAccessToken() or server side request and use it to get the page_token.

To get a longer-lived Page access token, exchange the User access token for a long-lived one, as above, and then request the Page token. The resulting Page access token will not have an expiry time at all.

Extended page tokens.

I have found no documentation to support the code below, but it has been tested to work.

try {
       $args = array(
                 'access_token' => $page_token
               );

       $deleted = $facebook->api('/'.$post_id, 'DELETE', $args);

} (catch FacebookApiException $e) {
       echo $e->getType() . " " . $e->getMessage();
}

If you don't have the post_id you can query the posts:

 $facebook->api('/'.$page_id.'/posts?fields=id');


In Facebook, an object posted by a user or those posted by others in an object owned by the user ( holder of the access token specified) can only be deleted. The same is the normal behaviour of Facebook.

Just make sure you are trying to delete those objects posted by the owner of the Facebook access token.

Eg. A user can delete content on his wall, events created by him, comments or posts by others in events created by him, or those comments or posts created by him in others walls or objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消