how to check special permissions in facebook
Asked Answered
C

4

11

how can i check in javascript if user has granted my site the publish stream permission

?

Colonize answered 13/10, 2009 at 22:8 Comment(0)
S
11

I had this same problem but couldn't find any sample code. Anyways, I came up with this, which works for me. Hope this helps someone.

FB.api('/me/permissions', function (response) {
            var perms = response.data[0];

            if (perms.publish_stream) {                
                // User has permission
            } else {                
                // User DOESN'T have permission
            }                                            
    } );
Serle answered 25/4, 2012 at 17:12 Comment(0)
T
7

The API method you're looking for is Users.hasAppPermission. You could call it directly from JavaScript, but it will probably be more efficient to write your own HTTP method, that calls it via API and returns "true" or "false" via JSON.

There is also a filed bug (13378) that Users.hasAppPermission has no Graph API equivalent.

Terr answered 14/10, 2009 at 3:51 Comment(1)
It's in the Graph API now: graph.facebook.com/me/permissions - developers.facebook.com/docs/reference/api/userBonnet
M
5

In the new Graph API (including via JavaScript) this can be accomplished by accessing "/[user]/permissions".

From the User object documentation:

permissions

The permissions that user has granted the application.

array containing a single object which has the keys as the permission names and the values as the permission values (1/0) - Permissions with value 0 are omitted from the object by default; also includes a type field which is always permissions.

Microcline answered 29/8, 2011 at 21:28 Comment(0)
U
0

Looks like is not supported. At least is not documented.

You may read from javascript once the permission is granted though.

Uncertain answered 13/10, 2009 at 22:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.