Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Last active December 21, 2015 00:48
Show Gist options
  • Save niraj-shah/6222857 to your computer and use it in GitHub Desktop.
Save niraj-shah/6222857 to your computer and use it in GitHub Desktop.
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