Facebook graph page/post insights - permissions error - facebook

I have 2 facebook pages where im admin on, lets call them page_a and page_b
if i run this for page_a it works as expected:
HTTP GET -> {PAGE_A_ID}/insights?metric=page_fans_country
{
"data": [
{
"name": "page_fans_country",
"period": "day",
"values": [
{
"value": {
"AR": 4,
"AT": 13,
"AU": 7,
"BE": 16,
....
the page access token i use have the following scopes: read_insights, manage_pages, pages_show_list and public_profile
but when i then try to query details about a post i get this
HTTP GET -> {PAGE_A_ID}_{PAGE_A_POSTID}/insights?metric=post_impressions,post_impressions_unique,post_video_views,post_video_views_unique&period=lifetime
{
"error": {
"message": "Permissions error",
"type": "OAuthException",
"code": 200,
"error_subcode": 1504029,
"is_transient": false,
"error_user_title": "User doesn't have enough permissions to load insights",
"error_user_msg": "You do not have enough permission to view the metric.",
"fbtrace_id": "..."
}
}
it works when i do the same for page_b
HTTP GET -> {PAGE_B_ID}_{PAGE_B_POSTID}/insights?metric=post_impressions,post_impressions_unique,post_video_views,post_video_views_unique&period=lifetime
{
"data": [
{
"name": "post_video_views",
"period": "lifetime",
"values": [
{
"value": 0
}
],
....
the page access token for page_b has same scopes as the one for page_a
I can see all the numbers in facebooks UI, but i cant not access it via the API, anybody had similar issues before?, im stuck and dont know where to go from here.
All above code have been ran in the Facebook Graph Explore, with newly generated tokens.
Any inputs on where to go from here are appreciated.

As mentioned in a comment by #xuantuan58 this seems to be a bug in the FB API.
https://developers.facebook.com/support/bugs/301627877187448/
And may also be related to this bug report: https://developers.facebook.com/support/bugs/2380273985356980/
I have noticed it is only occurring on certain users & pages but as of yet am unable to see a pattern. Sometimes an error will not be returned by the API and instead just an empty data array. If you think there should be data in the response try using the graph explorer tool as I've found that will sometimes give better error responses.
https://developers.facebook.com/tools/explorer/
UPDATE: This issue has now been marked as resolved by Facebook. I have been testing and found this issue has indeed been fixed.

We got the same issue a couples day ago. After playing with scopes we found that if business_management scope is grant then we got the data. But clearly, from its document business_management is not required for reading Page Insights. Hopefully, there is someone has better insights

Related

API Graph Facebook - Creation page User TEST

I'm trying to use the Graph api to create pages. So I have an application type Entreprise, and a Test User. I tried this:
Post request to [userTest_id]/accounts/
Params:
{
"name": "Test Page One",
"about": "This is the first page created to check the api",
"cover_photo": {
"url": "https://i.etsystatic.com/6293506/r/il/ea9cf8/1809124703/il_fullxfull.1809124703_swn3.jpg"
},
"picture": "https://i.etsystatic.com/6293506/r/il/ea9cf8/1809124703/il_fullxfull.1809124703_swn3.jpg",
"category_list": "[\"174177802634376\"]"
}
I use user token
I get this error:
{
"error": {
"message": "Unsupported post request. Object with ID '[userTest_id]' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "ATSiLLBx2O1yOuPRFxq4r4V"
}
}
I've followed this doc:
https://developers.facebook.com/docs/graph-api/reference/user/accounts/#Creating
What I'm missing plz ?
Thanks.
Facebook API doesn't allow creating Pages in the "real world" scope. You may do it for test users (created on the Role tab) or, in production, you have to get special approval from Facebook (not just permission).

Facebook API Lead retrieval for internal business app should i submit for App Review

I am building a dedicated CRM solution and it is supposed to show the list of Facebook leads of the client and then convert manually it to internal lead . I am managed to setup a websocket client and Facebook is sending me lead details including leadgen_id.
{
"object":
"page" ,
"entry": [{
"id": "*****" ,
"time": 1627211279 ,
"changes": [{
"value": {
"form_id": "******" ,
"leadgen_id": "******" ,
"created_time": 1627211277 ,
"page_id": "******"} ,
"field": "leadgen"}
]}
]}
Then i have created an user access_token using Facebook's graph api and requested for the details of the leadgen_id using api endpoint
https://graph.facebook.com/v11.0/<LEADGEN_ID>?access_token=<ACCESS_TOKEN>
I was able to get the details of the test lead I created with the Facebook 's lead testing tool. But when accessing the production leadgen_id I am getting an exception with following as response.
{
"error": {
"message": "Unsupported get request. Object with ID '<LEADGEN_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "*********"
}
}
Then I have tried using a system user token and its not even working for the test leads. In some part of documentation it is saying that I need to complete App review to access live data using lead_retrieval and in some other part of documentation its quoted that I don't need app review to use API for internal users . And I don't get the point of creating a 'login with Facebook' for this internal app specific for one user .
Is there anyway other way than completing app review to access lead details using leadgen_id ?
Its turns out I need to complete the app review specifying it as a 'Server to server app' on the review description, which doesn't need any Login with facebook button . Got the idea from https://developers.facebook.com/docs/app-review/resources/sample-submissions/server-to-server/

What is the minimum setup to post an Ad using Facebook Marketing API?

We need to integrate with Facebook Marketing API for a simple workflow. A user should be able to login to the app with Facebook and allow us to post ads on their behalf.
It seems simple, however we are hitting a strange bug while creating an AdSet. While performing a correct call:
curl -i -X POST \
"https://graph.facebook.com/v8.0/act_XXX/adsets/?status=PAUSED&optimization_goal=REACH&daily_budget=10&name=Test%20Ad%20Set&campaign_id=XXX&targeting=%7B%22geo_locations%22%3A%7B%22countries%22%3A%5B%22US%22%5D%7D%7D&end_time=2015-03-12%2023%3A59%3A59-07%3A00&access_token=<access token sanitized>"
With token permissions:
{
"perms": [
"ads_management",
"ads_read",
"public_profile"
],
"user_id": XXX,
"app_id": XXX
}
and with POST payload:
{
"status": "PAUSED",
"optimization_goal": "REACH",
"daily_budget": "10",
"name": "Test Ad Set",
"campaign_id": "XXX",
"targeting": "{\"geo_locations\":{\"countries\":[\"US\"]}}",
"end_time": "2015-03-12 23:59:59-07:00"
}
We get a response reading:
{
"error": {
"message": "An unexpected error has occurred. Please retry your request later.",
"type": "OAuthException",
"is_transient": true,
"code": 2,
"fbtrace_id": "AUV0_CHdqPNtGuqNd-ZHCW6"
}
}
This seems like a bug on FB side, however, they seem have a track record of returning this message when something is wrong with a request or permissions. While we are waiting for their support response, I am wondering if something could be wrong on our side.
The app is pretty bare bone right now, and we are playing only with the Graph Explorer tokens. Should we go through some review process to get rid of the error? Posting ad campaigns works correctly, so this is even stranger.

Facebook App Permission issue when deleting some Comments

I am having issues deleting a comment on my page via Facebook Graph API. My app has subscribed to all necessary permissions and the page token I have has all the necessary permissions for post moderation, including pages_manage_engagement and pages_read_engagement permissions indicated here https://developers.facebook.com/docs/graph-api/reference/comment/#deleting.
Ironically, I am able to delete some comments made by admins on my page but for others, I get the following exception:
{
"error": {
"message": "(#200) App does not have sufficient permission for this action",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "AEb1bLEPhjgypCFBLr2FjiI"
}
}
When trying to get the comment from Facebook to check if It can be deleted, I get
{
"id": "xxxxxx",
"from": {
"name": "xxxx",
"id": "xxxxx"
},
"message": "some message to delete",
"is_hidden": false,
**"can_remove": true,**
"can_hide": false
}
Please what am I doing wrong?
Any help would be appreciated.
I am using the following endpoint
https://graph.facebook.com/v6.0/comment_id
with an Http delete request.
PS: v7.0 has the same result.

Can't get Facebook user id by Graph

I'm working on an iOS app and noticed that one user is not loaded when I do a requestForMyFriends.
After looking more into this it seems that the Graph API explorer also doesn't return anything for the particular Facebook user. It's a user and not a Fanpage or something.
So:
I've the page for example (which when I enter In my browser will bring up the Page nicely): https://www.facebook.com/user-name
https://graph.facebook.com/https://www.facebook.com/user-name
Will return:
{
id: "https://www.facebook.com/user-name"
}
https://graph.facebook.com/user-name
Will return:
{
error: {
message: "Unsupported get request.",
type: "GraphMethodException",
code: 100
}
}
http://findmyfacebookid.com/ wil return nothing.
The graph API will return:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
I'm trying to reproduce this with my test Facebook account and put all restrictions to the max but I always get a nice result with a FacebookId.
My question:
What settings do I need to change to my test Facebook account to reproduce this problem?
"Unsupported GET Request" covers many situations, but at the root the message means you tried to request something via the API which is not available to you via the API
For a request which attempts to retrieve data about a known username or user ID the most likely reasons are:
User has blocked your app
User has disabled all platform apps in their privacy settings
User has deactivated their account
User has deleted their account
if i had to bet, I'd say it's the second one in this case
The problem is the parameter, you don't have to pass in the whole URL of a profile, just the username/profile-id.
For example: we want to get the info of Mark Zuckerberg. His Facebook username is zuck. The URL would be https://graph.facebook.com/zuck and will return the following output
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Using https://graph.facebook.com/4 (4 is the profile id of Mark Zuckerberg) would produce the same output.
Edit
After some further investigation it turned out that said user might have deactivated her account and that is why you see this error. I have used a testuser of one of my apps, went to Settings -> Security -> Deactivate my account and taxa, every request to the Graph API returned the result you're seeing.