Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Facebook API: Banning Users From Your Application

Facebook API: Banning Users From Your Application

2

If you’re unlucky, you may have a few users who like to spoil the fun for all the other users using your application on Facebook or even Facebook-connected apps. Luckily, the Graph API lets you easily ban or unban users from using your application. In order to ban or unban a user, you need to use your application access_token and know the user’s Facebook User ID.

Application Access Token

Your application access_token is made up of the App ID and App Secret used to access the API. You can get your details from the Facebook Developer Portal.

Facebook - App Details

To create your App access_token, just append the App Secret to the App ID, separated by the pipe character (‘|’), e.g. 1234567890|abcdefghijklmnopqrstuvwxyz.

Accessing the Existing Banned User List

To see which users have already been banned, make a API call to endpoint: {app_id}/banned/ using your App access token. Or in PHP as follows:

Banning / Unbanning Users

Banning a user is just as easy, and simply required a POST call to the Graph API with a comma separated list of User IDs you want to ban. In PHP, you can do the following to ban one or more users:

The code for unbanning a user  is also included in the above example. To unban, you need to make a DELETE API call to the {app_id}/banned/{user_id} endpoint using the app access_token.

What Banned Users See

If the banned user tries to access your application, they will be prompted with the below error message on login (when using the JavaScript SDK). Your application should also check if the user has been banned during runtime, in the case that they’ve already logged in, but didn’t logout since the ban took effect.

Facebook - User Banned Message

Facebook, Facebook Graph API, PHP

2 comments on “Facebook API: Banning Users From Your Application”

  1. beniamin qojle says:
    March 21, 2014 at 10:21 PM

    can any person unban my game game bcs in fb i am banned and the adm of the gamedont listen that someone hac cheat in my account he has hacked my account first then when i recovered he have do the cheat and the gamehave banned me plzzzzzzzzzz

    Reply
    • Niraj Shah says:
      March 23, 2014 at 7:06 PM

      What would be the point of banning someone if they can just un-ban themselves? Only someone who knows both the App ID and App Secret can un-ban someone, and it’s usually the application owner and developers working on the app. You have no choice but to rely on them to un-ban you.

      Reply

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy