I simply want to pull insight data for my company utilizing the Facebook Graph API. I am testing using https://developers.facebook.com/tools/explorer.
When I enter https://graph.facebook.com/MY_ID/insights? and an Access Token I would expect to see JSON data with such data as Page_Views. However I only see this:
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/MY_ID/insights?format=json&since=1337268417&until=1337527617",
"next": "https://graph.facebook.com/MY_ID/insights?format=json&since=1337786817&until=1338046017"
}
}
Any suggestions on the URL or perhaps I shouldn't be using Graph API to view Page_Views?
From the Page object documentation, for the insights connection:
Permissions: A valid access_token with read_insights permission for a user
authorized to view the Page's insights
In the explorer click the Get Access Token button, change to the "Extended Permissions" tab and check the "read_insights" box, then click the button and try again.
For anyone else who might run into this issue that wants to view a 'Page' nstead of a user in say v2.4 you might need to use 'Get Page Token' in the 'Get Token' field otherwise you could be seeing what ToddN saw
Related
I would like to find the id (app-scoped) for someone who has posted a comment on a public page.
For example, I get a list of recent posts/comments on the NY Times page via:
v2.11/nytimes/feed?fields=comments.limit(10){message,created_time,from},name,message,from&limit=2
The data returned looks like this:
"comments": {
"data": [
{
"message": "Wouldn’t know. Not paying $13/mo for this.",
"created_time": "2017-12-10T05:57:18+0000",
"id": "10151412260164999_10151414049324999"
}
],
There is no from field. The same is also true if I attempt to view the comment directly using it's id with
v2.11/10151412260164999_10151414049324999?fields=from,message,created_time
I have tried using the Facebook Graph API Explorer, using both my User Token, as well as an App Token.
Since v2.11 of the Graph API, you need a Page Token to get user data of comments: https://developers.facebook.com/docs/graph-api/changelog/version2.11#gapi-90
User information will not be included in GET responses for any objects owned by (on) a Page unless the request is made with a Page access token. This affects all nodes and edges that return data for objects owned by a Page.
In other words: You can only get user information if you manage the Page.
Edit: Since the latests update in the Graph API, you have to get the App reviewed and you must go through Business Verification or Individual Verification. (thanx #Guiman04)
Please check whether you are using the accessToken for the page you are trying to get data from, i had same issue, and was resolved by using the correct accessToken for the page.
When I test the Graph API Explorer from facebook site and write the following parameters:
https://graph.facebook.com/'groupid'/feed?access_token='my access token'
it returns
{
"data":
[
]
}
I tried it with several group ids and all return the same result, while if I try members instead of feed it returns the list of members.
Is there a bug in the feed of a group?
Here is how you can generate the issue:
Get an access token: xxxxx
Get any Group ID: 123456
Make the graph api explorer call to retrieve the group's wall based on the group id
https://graph.facebook.com/123456/feed?access_token=xxxxxxx
The thing is I first thought the problem was from my code, but when I tried it from facebook graph api explorer I found out that its not returning any results.
Please I would really appreciate the help as this is part of my master's project and the due is within two weeks!!
Assume group id is 481298561918120, please visit https://developers.facebook.com/tools/explorer/?method=GET&path=481298561918120%2Ffeed
If you see
{ "data": [ ] }
, you should click the "Get access token" button on your right-hand, then click/check "user_groups". Finally, click "Get Access Token" and process the dialog to grant permission
After you granted the permission, try to click "Submit" button. Now you should able to see the feed.
Conclusion: make sure you have granted user_groups permission. You can check the permission on "Scope" field at https://developers.facebook.com/tools/debug
As of api version 2.8 the following requirements should be met.
Any valid access token if the group is public (i.e. the group's privacy setting is OPEN)
If the group is not public:
The user_managed_groups permission should be acquired
And user should be an admin of the group you are about read.
Here is the catch
To use the user_managed_groups permission you need to submit your app for review.
Login Review: https://developers.facebook.com/docs/facebook-login/review/what-is-login-review
Otherwise you are left with the response:
{
"data": [
]
}
Group Feed API Source: https://developers.facebook.com/docs/graph-api/reference/v2.8/group
I have a facebook account I KNOW has articles posted to the open graph as read actions under the news.reads global namespace (I can see them under the News aggregation in my timeline) but when I try to get a list of them using this api address:
https://graph.facebook.com/me/news.reads?access_token=[my access token]
it returns:
{
"data": [
],
"paging": {
"next": "https://graph.facebook.com/me/news.reads?access_token=[my access token]&offset=25&limit=25"
}
}
as though there were no articles posted at all. I checked my permissions and cant find anything that might be causing this issue. Anyone know how I should be accessing this data correctly? Thanks!
You need the user_actions.news Permission in order to access the user's list of news reads, otherwise the array comes back empty
I am able to add custom tabs to my Facebook pages, by using the Graph API,
[https://graph.facebook.com/page_id/tabs] and using HTTP POST.
However, I am unable to add custom tabs to my Facebook application's profile page. Infact the API, [https://graph.facebook.com/page_id/tabs], with HTTP GET also fails.
(I mean, I cannot even get the tabs for my Facebook application's profile page with the API.)
What am I doing wrong?
Here I am listing what I am trying to do:
I get an access_token (say a1) for a user (admin_user) using the manage_pages permission.
With this access_token (a1), I use Graph API, >[https://graph.facebook.com/me/accounts] and get back a list of pages (pages and application profile pages):
{
"data": [
{
"name": "Bg",
"access_token": "***",
"category": "Industrials",
"id": "*****"
},
{
"name": "Testapp2Pip",
"access_token": "*******",
"category": "Application",
"id": "***"
},
Now I use the Graph API, [https://graph.facebook.com/page_id/tabs]
Case 1. If I use the page_id for the background page (which is a normal page) and the corresponding access_token, I get back the tabs for the page.
Case 2. If I use the page_id for the Testapp2Pip page (which is an application profile page) and the corresponding access_token, I get an error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException"
}
}
What am I doing wrong here? How do I get the tabs for an application profile page? Also, I would actually want to add custom tabs to the application profile page by using Graph API.
Have you added the app to the app profile page, and/or double checked that it is added as an app? It seems odd, but you can add/remove the app from the apps own page. I'm guessing if the app isn't added, then it wouldn't have access to the page information.
An alternative option is to get an access token for the application, not the current user. This page has instructions for getting an access token for the app, instead of the user. Scroll down to the "App Login" section.
http://developers.facebook.com/docs/authentication/
Okay, so this is a bug. I have filed the bug with Facebook.
I want to get insights data of a facebook page. I have tried with graph api with this url:
https://graph.facebook.com/149279625121774/insights/?access_token=XXXX
but it gives empty data:
{ "data": [
], "paging": {
"previous": "https://graph.facebook.com/149279625121774/insights/...",
"next": "https://graph.facebook.com/149279625121774/insights/..."
}
}
'149279625121774' is the page id.
Is anybody help me for this.
UPDATED ANSWER:
Insights can be retrieved only as an array. To read Insights you need
a generic access_token for the publicly available application_active_users metric
a generic app access_token for all Insights for that app
read_insights permissions for all apps, pages and domains owned by this user
For more details on which insights are available please review the FQL Insights table
Here are my comments:
Most likely you don't have the read_insights permission.
The user authenticated should be the owner/admin of the page!
Remove the trailing slash /
I found the solution.
You must change the order of the scope parameter:
Try
email,read_insights,manage_pages
Instead of
email,manage_pages,read_insights