Admin.banUsers
From Facebook Developer Wiki
Contents |
Description
Prevents users from accessing an application's canvas page and forums.
Parameters
| Required | Name | Type | Description | |
| required | api_key | string | The application key associated with the calling application. If you specify the API key in your client, you don't need to pass it with every call. | |
|---|---|---|---|---|
| sig | string | An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application. Facebook computes the signature for you automatically. | ||
| v | string | This must be set to 1.0 to use this version of the API. If you specify the version in your client, you don't need to pass it with every call. | ||
| optional | format | string | The desired response format, which can be either XML or JSON. (Default value is XML.) | |
| callback | string | Name of a function to call. This is primarily to enable cross-domain JavaScript requests using the <script> tag, also known as JSONP, and works with both the XML and JSON formats. The function will be called with the response passed as the parameter. | ||
| required | uids | string | A JSON-encoded array of user IDs to ban. |
Example Requests
Example PHP for banUsers unbanUsers and getBannedUsers
<?php
// Get these from http://developers.facebook.com
$api_key = 'xxx';
$secret = 'xxx';
// the facebook client library
include_once '../../client/facebook.php';
$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$user = $facebook->require_login();
// Ban users
if (isset($_REQUEST["Ban"]))
{
$tm = array('uids'=> $_REQUEST["id"]);
$x = $facebook->api_client->Admin_banUsers($tm);
echo("1 = Ban Success, 0 = Fail.");echo("<br />");
echo(" Result = ");
echo($x);
}
// UnBan users
if (isset($_REQUEST["UnBan"]))
{
$tm = array('uids'=> $_REQUEST["id"]);
$x = $facebook->api_client->Admin_unbanUsers($tm);
echo("1 = UnBan Success, 0 = Fail.");echo("<br />");
echo(" Result = ");
echo($x);
}
//Show currently banned users.
$z = $facebook->api_client->Admin_getBannedUsers();
echo("<br />");
echo("Currently Banned Users");
echo '<pre>';
print_r($z);
echo '</pre>';
?>
<form action="" method="post" enctype="multipart/form-data">
<table align="center" border="0" width="100%" cellpadding="5" cellspacing="0" >
<td class="main_simple_txt">User to ban </td>
<td>
<input type="text" name="id" value="" />
</td>
</tr>
<tr>
<td ></td>
<td><input type="submit" name="Ban" value="Ban the User"/></td>
</tr>
</table>
</form>
<form action="" method="post" enctype="multipart/form-data">
<table align="center" border="0" width="100%" cellpadding="5" cellspacing="0" >
<td class="main_simple_txt">User to Unban </td>
<td>
<input type="text" name="id" value="" />
</td>
</tr>
<tr>
<td ></td>
<td><input type="submit" name="UnBan" value="Remove Ban"/></td>
</tr>
</table>
</form>
Response
This method returns true if the users were successfully banned.
