How to check if a user granted certain permission to an app (using FQL)

  1. Previous
  2. Next
  3. Recent

    1. Signs 'He' May be Cheating on You
    2. 7 Vows of Hindu Marriage - Know What 'Saat Vachans' Mean
    3. RuPay vs Visa vs Mastercard vs American Express- A Comparison
    4. What is RuPay? Everything You Need to Know About India's Domestic Payment System!
    5. Top 10 Online Portals to Find a High Paying Job in India
    6. Top Indians who Revolutionized the IT Sector in India
    7. 8 Initiatives by Narendra Modi that Could Change the Future of the Nation
    8. 8 Work-from-home Jobs for Housewives, Students, and Part timers
    9. Complete Company Registration Process in India - Explained
    10. Change Name in India in 5 Steps - Filing Affidavit, Newspaper Ad & Gazette Notification

Facebook apps can ask user for lot of permissions – permission to read personal information, likes, posts, to post update and many more.

Functionality of apps depend on these user data, so its important to check if certain permission(s) is granted to the app by the user or not.

Here is the code that checks if ‘publish_stream’ permission is given to an app or not. [The code for checking other permission(s) would be similar.]


$config = array( 'appId' => '2454153xxxxxxxxx', 'secret' => 'xxxxxxxxxxb1729xxf4xx79bxxx71x', );
$facebook = new Facebook($config);
$user_id = $facebook->getUser();

$fql1 = 'SELECT publish_stream FROM permissions WHERE uid=me()';
$check_param = $facebook->api(array( 'method' => 'fql.query', 'query' => $fql1));
echo "<p>Permission Granted to app</p>";
echo "<p>Not granted</p>";


If the permission is granted, the output value for the FQL query should be 1, otherwise 0. We can check for more permissions in the similar manner.

You check this code in operation in my Facebook app –¬†Flip My Update. In the app, if a user doesn’t allow publish_stream permission at first, then he is asked for the permission again.

blog comments powered by Disqus