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
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.
I'm trying to get useful data from the Insights section using the the Graph API Explorer.
I've tried different metrics and dates, and the results for data is always empty.
I was able to look at my page dashboard for number of likes and select a range based on that, but I still don't see any data.
If the access_key is an issue, would it return an error saying so, or just return empty results?
Here is the debug output from a popular company that I would imagine has new likes in the past few weeks.
=== Query
curl -i -X GET \
"https://graph.facebook.com/v2.8/14226545351/insights/page_positive_feedback_by_type?since=1487788679&until=1490812690&access_token=<access token sanitized>"
=== Access Token Info
{
"perms": [
"user_likes",
"manage_pages",
"pages_show_list",
"public_profile"
],
"page_id": 167544343274096,
"user_id": "10152810337959467",
"app_id": 145634995501895
}
=== Parameters
- Query Parameters
{
"since": "1487788679",
"until": "1490812690"
}
- POST Parameters
{}
=== Response
{
"data": [],
"paging": {
"previous": "https://graph.facebook.com/v2.8/14226545351/insights?access_token=<access token sanitized>&pretty=0&since=1484764668&until=1487788679&metric=page_positive_feedback_by_type",
"next": "https://graph.facebook.com/v2.8/14226545351/insights?access_token=<access token sanitized>&pretty=0&since=1490812690&until=1493836701&metric=page_positive_feedback_by_type"
},
"__debug__": {}
}
=== Debug Information from Graph API Explorer
- https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=14226545351%2Finsights%2Fpage_positive_feedback_by_type%3Fsince%3D1487788679%26until%3D1490812690&version=v2.8
Is anyone able to give an actual working example? I have not come across any yet.
I discovered in the Graph API explorer, when you generate an access token, you need to give it permission "read_insights".
Also, this will only work on a page which your account has access to that given object.
Unfortunately the documentation is pretty vague in this area and there was no permissions error message give.
This might be a bit late, but better late then never I guess :)
On this Facebook docs page you can find a list of all the metrics you can use.
As for empty data, I had the same problem. I could never find how to get data from Facebook Insights; but thanks to the cheatsheet, I can give you an example:
Facebook Insights Example
https://graph.facebook.com/{page_id}?fields=insights.metric(page_fans)&access_token={access_token}
EDIT
Also, user Ravi Patel has a great, working example showing how to get insights from your posts:
/{page-id}/posts?fields=insights.metric(post_impressions_fan,post_engaged_users)
Original question
When in Facebook Graph Explorer I executed /me/friends command from docs, I get next response:
{
"data": [
],
"summary": {
"total_count": 68
}
}
So, based on response, I have 68 friends (it's true), but data array is empty, and I don't see my friends in array.
What I do wrong? I think, maybe I need to config my application? but I don't know what exactly t config. Help, please
With the new Graph API (v2.0), your application must ask for the user_friends permission in order to retrieve friends. Additionally, this new permission now only returns friends who also use the same application.
If you want to get the complete friends list for tagging / invite purposes, there are two new APIs you can use: /me/taggable_friends or /me/invitable_friends - the latter is only available to Games.
See this tutorial for more information.
I have a user, user_2. There is a post on their wall, made by user_1.
The URL is
https://www.facebook.com/user_1/posts/10150166228506188
I try to get the content using the Graph API, with this request:
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
I get this error:
{
"error": {
"type": "GraphMethodException",
"message": "Unsupported get request."
}
}
The access_token I am using is good, because requests to get things like statuses & images work fine:
https://graph.facebook.com/10150233707783933?access_token=ACCESSTOKENUSER_2
Result:
{
"id": "10150233707783933",
"from": {
"name": "American Steel",
"category": "Professional sports team",
"id": "203692078932"
},
"tags": {
"data": [
etc
The error seems to happen whenever I try to get items that have this kind of URL:
https://www.facebook.com/username/posts/item_id
The permissions my app has include these:
Why is this error occurring?
I think that, in order to access the posts directly through the graph api, you have to prepend the user id to the post id you see in the facebook url.
So in your example the facebook post url is :
https://www.facebook.com/user_1/posts/10150166228506188
And you try to get through the graph api :
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
BUT you should be doing :
https://graph.facebook.com/{id of user_1}_10150166228506188?access_token=ACCESSTOKENUSER_2
I noticed that all posts ids are formed like this by visiting :
https://graph.facebook.com/me/posts?access_token=...
Does this solve your problem ?
You're accessing the end-point of the post incorrectly. Every object on Facebook has a unique ID. Right now, it just so happens that they form it by appending different IDs together (your post is an example, <user_id>_<post_id>, and for a comment on that post it'd be <user_id>_<post_id>_<comment_id>). Facebook hasn't made public acknowledgment of this (not that they really have to, it's obvious) which makes me leary to rely on that paradigm for accessing data within the graph. This is because Facebook could change it at any point, and the fact that they haven't said "yeah append these 2 ids together and you can get something meaningful from this part of the graph" means they won't have to notify anyone about the change, you could just wake up one day and your app be completely broken and you'd have to find a work around quickly and while suffering down time.
The graph api works by accessing objects on Facebook by making a request to the API for that unique ID. So, you don't need to access (and can't access) your posts by going to graph.facebook.com/<user_id>/posts/<post_id>. Instead, you go to graph.facebook.com/<post_id>. You get the post_id from the /<user_id>/home or /<user_id>/feed end-point on the graph. There is no need to modify a post_id in order to fetch information about it from the graph.
Hope that helps
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