'Facebook API – how to get Page-Scoped User ID (ids_for_pages is empty)?
My goal is to identify authors of posts published on my Facebook Page, by matching them with user ID-s from my database, which ID-s are App-Scoped User ID-s (ASID).
I've generated User Access Tokens (through app) and extended it to long-lived access tokens. Then I've generated Page Access Tokens for all pages managed by users – listed via GET user/accounts
.
At first, I check the author of the post ({PID}
is Facebook Post ID):
curl -X GET 'https://graph.facebook.com/v6.0/{PID}?fields=admin_creator&access_token={ACCESS_TOKEN}'
That gives my ID
of user, which I believe is Page-Scoped User ID (PSID).
In order to make matching, I am trying to establish PSID-s for all pages managed by all users from my database:
curl -X GET 'https://graph.facebook.com/v6.0/{UID}/ids_for_pages?access_token={ACCESS_TOKEN}&appsecret_proof={APPSECRET_PROOF}'
Where {UID}
is user ASID, {ACCESS_TOKEN}
is Page Acccess Token and APPSECRET_PROOF
is hash generated from Page Access Token and App Secret. The app and the pages are owned by the same business (which is obligatory to use ids_for_pages
endpoint).
Unfortunately, the response is:
{"data":[]}
I've read the documentation – https://developers.facebook.com/docs/facebook-login/connecting-accounts (which recommends using App Access Token for ids_for_pages
) and similar StackOverflow question – Getting ids_for_pages from Graph returns empty (which recommends using Page Access Token for ids_for_pages
).
Therefore, instead of Page Access Token as {ACCESS_TOKEN}
I've also tried using (with corresponding APPSECRET_PROOF
):
- App access token (generated from App Secret)
- User access token (long-lived)
But without effect. I always get empty list as response.
I've even tried to change {UID}
(App-Scoped User ID) to:
- Standard Facebook Profile ID
- Page-Scoped User ID (which is what i want to get in response!), obtained from
admin_creator
field of fetched pages' posts
Nothing. Response is empty. I'm completely stuck.
As @04FS suggested, the reason could be something described in Facebook API documentation of ids_for_pages
(linked above):
Your initial call to the API may trigger an app review that can take approximately 48 hours to complete.
However, over 48 hours have passed since the question was asked and over 72 hours since my initial call to the API, but the response is still empty.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|