Graph API sharedposts edge empty data issue - facebook

I'm facing a problem with /sharedposts edge it keeps returning empty array
{"data": []}
I'd like to share my case exactly with you, may be I'm doing something wrong.
I'm using Graph API Explorer / API ver 2.3
I'm trying to track a fan page post, and get the users' ids who shared this post
The page post is public
All the sharing is public too
My application has read_stream permission granted (at least on the testing users)
I even tried that when I'm the page Admin, App Admin, and I did the sharing myself to my timeline, all permissions are granted and I added manage_pages permission.
I tried using the {post_id}/sharedposts
I tried using the {page_id}_{post_id}/sharedposts
Based on other posts in this regard on StackOverflow, I added limit.
All the above trials, keep giving me the same results
{"data": []}
Please advise me what's wrong with my App, please if anybody has a successful experience with this issue please share, or advise me where could I find the problem?!!!

There seems to be a known bug with this API endpoint. The behaviour you're describing is the same as in this bug report: https://developers.facebook.com/bugs/1404733043148335/

The /sharedposts endpoint will -only- retrieve posts from users who have -also- granted your app. This means that even though a post might be public on a users' timeline, unless they have also granted your app permissions, you will not be able to retrieve that post.
For example: a user posted to a page and the post is public. This post can be retrieved with an access token. Let's assume that the user also shared this post to their own timeline. But, since the user has not granted permissions to your app, you will not be able to see this post using the /sharedposts edge on the original post (on the page). This also holds if the user shared their post publicly to his timeline.
This behaviour is by design; the API is more restrictive in returning user data than the website is. This holds for multiple endpoint and this is one of the examples where it is the case.

Related

How to get my own Facebook user timeline using Graph API?

I would like to get all the posts and updates that are normally displayed in FB official application for MY account (this includes updates from my friends and liked pages).
I wasn't able to find any details how to get that, the only thing I've managed to get is my own posts.
Anyone got any experience with that using current Graph API verion (3.3)?
All the alternate FB clients (ex. Friendly) must be doing this somehow.
There is no way to get ANY data of users who did not authorized your App. Which means, there is no way to get posts of friends. You can only get your own friends, with the user_posts permission and the /me/posts endpoint. If some Apps access friend data without their authorization, they are most likely doing something that is not allowed.
Here is what I found in their API docs:
There are two scopes:
The user feed requires the user's permission
The public feed has fewer capabilities but doesn't require perms

Facebook API for Share returning empty results set

I am new to Facebook API. I am building a Facebook app to fetch all the name of people who shared, commented and liked a post in a tabular format. I am able to get the like and comment details through Facebook API but can not find and proper API to get the share details.
I am using
https://graph.facebook.com/post_id?fields=sharedposts&access_token=my_access_token.
This API is returning an empty result set. And I have granted all the available permission to the access_tokn. Can anyone tell me ,Is there any other API that I can use. I saw a option of scraping the Facebook page for share,but I don't want to go that way because Facebook keeps on updating every thing.
I'm having the same problem as you, but I think I'm going a little step forward.
Try adding a limit to your sharedposts and maybe it will return some data:
Try this way:
https://graph.facebook.com/post_id/sharedposts?access_token=my_access_token&limit=1000
That should work for a regular post.
EDIT: Maybe the problem could be that althought you have granted all the perms to the token, the people who share that posts have to accept that permission too.
Otherway your JSON won't return any data.
The /sharedposts endpoint will -only- retrieve posts from users who have -also- granted your app. This means that even though a post might be public on a users' timeline, unless they have also granted your app permissions, you will not be able to retrieve that post.
For example: a user posted to a page and the post is public. This post can be retrieved with an access token. Let's assume that the user also shared this post to their own timeline. But, since the user has not granted permissions to your app, you will not be able to see this post using the /sharedposts edge on the original post (on the page). This also holds if the user shared their post publicly to his timeline.
This behaviour is by design; the API is more restrictive in returning user data than the website is. This holds for multiple endpoint and this is one of the examples where it is the case.
Source: https://developers.facebook.com/bugs/1404733043148335

List of shares in FB graph api

I am trying to get a list of all users who share a given object on Facebook using the graph api.
There's been some useful info in this regard on stack exchange, here: Getting which users shared a post and here: List of people who shared on facebook
I experimented with the graph api's /{object-id}/sharedposts endpoint on the api. When I make the api call with a given object id which I have verified has been shared over 100 times (according to the /{page-id}/feed endopoint I am getting the object id from for said post), the api result invariably returns as such:
{
"data": [
]
}
So I am getting an empty array...is this because my access token will not allow me to get this information? I am not friends with any of the users sharing the post nor have I 'liked' the page in which the post originates from.
Just wondering if this is an authentication issue or if there's a different problem that I am running into. I've tried it with a few object IDs so I would like to ascertain exactly why there is no data when I use the /{object-id}/sharedposts endpoint.
Thanks!
There was a comment recently added to a response on the List of people who shared on Facebook post you referenced that solved this issue for me.
An access token with read_stream permissions is required, even if you have other permissions like read_insights. I was getting the same results as you until I added the read_stream permission.
However, you still may not get all or any of the shared posts. To see a share, it either has to be shared publicly or you must have permission to view that person's shared post.

Open Graph insights for specific post

We have a Facebook Application with custom Open Graph objects and actions.
We then use a App Access Token to post stories for a particular user from our backend with the normal Open Graph REST API. After the post-call succeeds we log the returned "id" of that post.
Now we would like to collect insight data (e.g. post_impressions_unique) for some of these individual posts/stories using the logged id's.
According to https://developers.facebook.com/blog/post/573/ we should be able to do something like:
https://graph.facebook.com/[POST ID]/insights
Even though this call seems to work using our normal App Access Token, no insight data is returned for the post/story.
Does anyone know if this is possible and how to do it?
We have been experimenting with a normal User Access Token and the "read_insights" permissions, but with no luck. I have read some similar questions but mainly regarding page-posts (this is an App Open Graph post/story).
EDIT:
The facebook article above only refers to "Page" posts. I'm looking for analytics on individual Facebook App Opengraph Posts/stories. It seems difficult to find any good information about this, has nobody attempted this with any success?
You must add insights into a permissions/Extended permissions
Article :
Getting Page Insights
In order to obtain Page Insights via the Graph API, you must use a Page access token, and you must have the read_insights permission. Click on the link below to see this working in the Graph API Explorer.

What controls which user posts are visible via the Facebook Graph?

I'm making requests like the following:
https://graph.facebook.com/USER_ID/posts?access_token=TOKEN
When the TOKEN is from the Graph API Explorer (from https://developers.facebook.com/tools/explorer logged in as my own user account), I see some posts for most users.
When the TOKEN is a user token for my own app and my own user account, resulting from the client-side flow[*], I see { "data": [] } for almost everyone.
What could cause the difference? As far as I can tell, the two tokens were given the same permissions (I get identical returns from https://graph.facebook.com/me/permissions?access_token=TOKEN for the two tokens).
All I can think is that the users whose posts I'm looking for aren't users of my app, but perhaps everyone is magically a user of the API Explorer. But the info I want to see about them is visible to me, both on their user page and from Graph using the API Explorer token, so surely this can't be a security restriction: I can get a token that shows me the information I want, but my app can't. Hence:
why aren't the posts visible to me when using my app?
what do I do about it?
our current theory is that the API explorer has special privileges to access public data, and other apps can't get that. Is this really the case, or is there something I could do with my app to view public data via /posts?
[*] Using the URL: https://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=manage_pages,read_stream,read_requests,user_location,user_activities&response_type=token
I see what you are saying, I tested it myself and I get the same.
Here's what I think is going on, but it's just a guess.
From what I just tested, the data that comes back when using the graph explorer app is public data of the user, like new friends and public posts.
It's the same exact data I can see if I go to the profile of the user in facebook.
Why doesn't your app get that public data?
Well, facebook grant special privileges to certain apps, and in the case of the graph explorer, which is their app, it's not far fetched to think that they did just that.
To test the theory I removed all permissions I have for the graph explorer and tried to get the posts of a user which is not my friend, and indeed I got the same results.
When I tested it with "me/posts" I got my posts, and not just the public ones.
If you remove the permissions from your own app then even your posts will return with data: [].
Your app can only get the data for the logged in user and his friends.