Facebook: get list of pages that a user is admin of

后端 未结 10 531
陌清茗
陌清茗 2020-12-07 08:50

I\'m using the graph api.

I have a logged in user, and want to get back a list of page ids of all the pages that the user is an admin of.

Is there a way of d

10条回答
  •  广开言路
    2020-12-07 09:13

    With the new GRAPH API v3 with Javascript use the 'tasks' field instead of 'perms' field.

    //Example JS Call
    FB.api('/me/accounts?fields=name,picture.type(square),access_token,tasks', function(response) {console.log(response)});
    
    //Example Response
    {
          "name": "Engage",
          "picture": {
            "data": {
              "height": 50,
              "is_silhouette": false,
              "url": "https://scontent.xx.fbcdn.net/v/t1.0-1/c1.0.50.50a/p50x50/430597_259746387431503_2144341304_n.jpg?_nc_cat=103&_nc_eui2=AeGVrU8Wxe7k5BMvRXOEAcUo9dMIxyeMP9POPkYDwfgdRl8QquAtz1GcwXpJaK4z_0o&_nc_ht=scontent.xx&oh=e5b952a4adbbcd1b1af6b71b688f7284&oe=5CF9A64C",
              "width": 50
            }
          },
          "access_token": "XXXXXXXXXX",
          "id": "253263371413138",
          "tasks": [
            "ANALYZE",
            "ADVERTISE",
            "MODERATE",
            "CREATE_CONTENT",
            "MANAGE"
          ]
        }
    

    Instead of looking of 'ADMINISTER' within the array, look for 'MANAGE'.

    Full info here: https://developers.facebook.com/docs/pages/access-tokens

提交回复
热议问题