Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ban a user from your Facebook Application using PHP
<?php
// change these to match your app
$app_id = '1234567890';
$app_secret = 'abcdefghijklmnopqrstuvwxyz';
// init facebook class
$facebook = new Facebook( array( 'appId' => $app_id, 'secret' => $app_secret ) );
/* Ban Users */
// call POST {app_id}/banned/ using app access_token and comma separated list of uids
$ban = $facebook->api( $app_id . '/banned', 'POST', array(
'access_token' => $app_id . '|' . $app_secret,
'uid' => '1234567890,5678901234'
) );
// $ban will return true if successful
print_r( $ban );
/* Unban Users */
// call DELETE {app_id}/banned/{user_id} using app access_token
$unban = $facebook->api( $app_id . '/banned/' . $user_id, 'DELETE', array( 'access_token' => $app_id . '|' . $app_secret ) );
// $unban will return true if successful
print_r( $unban );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.