4

I have the following Graph API call: me/accounts?fields=access_token,name,id,perms that I use to get the page tokens from the user.

Now I would like to filter this by perms="CREATE_CONTENT". How can I filter this Graph API call?

I'm using the C# Facebook.net SDK. Currently I use this code:

client.Post("me/accounts", new { fields = "access_token,name,id,perms" });

Kees C. Bakker
  • 32,294
  • 27
  • 115
  • 203

2 Answers2

0

You can't directly filter this in the API, but it would be quite easy to do from c#- you're getting an ICollection from the Facebook.JSONObject response, so you can just use linq to filter it - Filtering collections in C# has a pretty good explanation of how to achieve this.

Community
  • 1
  • 1
Reuben Thompson
  • 351
  • 5
  • 10
0

Opening caveat: I do not know C#, but I regularly work with the Facebook in other programming languages.

Facebook has a number of "Publish Permissions" as part of its Extended Permissions. I'm assuming you're already requesting one or more of these permissions from your users. (I don't see a create_content listed; that's the only reason I mention it.) Let's say, for example, you requested the create_event permission from your users.

Try accumulating the Facebook User IDs into a list, and then issuing a FQL query using the Facebook SDK client for the permission(s) you're interested in:

List<int> facebookUserIds = new List<int>(1, 2, 3);
var query = string.Format("SELECT uid, create_event FROM permissions WHERE uid IN ({})", string.Join(",", facebookUserIds));

dynamic parameters = new ExpandoObject();
parameters.q = query;
dynamic results = client.Get("/fql", parameters);

The response you receive will have properties like this (here, in JSON format):

{
  "data": [
    {
      "uid": 1, 
      "create_event": 1
    },
    {
      "uid": 2, 
      "create_event": 0
    }
    {
      "uid": 3, 
      "create_event": 0
    }
  ]
}

Of course, 0 means permission denied, and 1 means permission granted for the App ID you're using to authenticate with the Facebook API.

Note: Users will only be returned in the response if they've previously authenticated your app (of the most basic level of permissions); but this shouldn't be an issue.

Jacob Budin
  • 9,753
  • 4
  • 32
  • 35