Reading facebook post using graph API which app posted - facebook

My application is posting on wall on behalf of the user with user access_token. Once it is posted I get back the post_id which is persisted in DB. An an application I would like to query the post using the post_id to collect some basic insights like comments and likes. I can't get my app to query the data.
I tried stream table but doesn't return data as an app. I get "GraphMethodException" code:100
I checked privacy settings on post but that doesn't include permission for an app
I tried GraphAPI /post_id which returns same error as stream table
I tried insights table with post_impressions metric with no luck. I couldn't give the post_id so tried removing the user_id part from post_id(xxxx_yyyy where xxxx is the userid)
What kind of permissions do I need to request user to grant my application stream_read permission?
How do I query insights table with the post_id that I have?

You can only read the user wall with an active user access token, and the read_stream permission.
About the insights: maybe with this graph connection?
/[post-id]/insights
Well, it gives me nothing for a valid post id. But i am sure you can only get the insights of pages, not user accounts.
See here (about pages, but maybe useful additional info): Unable to access a post's insights for someone else's page
One more reason why it will not work, just popped up in my head:
If you go to a facebook page, you have the insights view as admin. Nothing like that on a user profile. So the only thing you can track is how often a link to your app has been clicked after posting it to a user profile. You can easily add tracking information to the link too, so you always know from which profile the click comes.

Related

Facebook Graph API unable to get comments from user's post

The Facebook Graph API seems no way to get any comments other than user itself posted from users' any Post, Album, Photo or Video nowadays. The /{object-id}/comments doc said A User can only query their own comments. Other users' comments are unavailable due to privacy concerns., also For the following nodes, the /comments endpoint returns empty data if you read it with a User access token:.
Does it really means Facebook Graph API unable to get user post's full comments in any way?
If this is for "personal use" your own user token then yeah you won't have a choice to bring anything else but if you're using a Page Token for a page that you manage then you can get the posts and comments but I'm currently unable to get the Comments "from" data so I can know who the User is (Name)

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

Facebook FQL query to stream table for posts by user is returning just one post

I'm posting to Facebook FQL the following query: SELECT post_id, comments, message FROM stream WHERE source_id=me() and its just returning one post. Whats going on? I thought it would send all of my posts. Is it correct to be using source_id?
** EDIT **
Do you think it has something to do with my subscription to an application? Im accessing the user from the application.
Make sure you have read_stream permissions it sounds like you are only getting public posts.
To read the stream table you need
read_stream permissions for all posts that the current session user is
able to view
read_insights permissions to see post impressions for any
posts made by a Page owned by the current session user

FQL: privileges to see a friend's posts

I'm trying to get all the posts of a friend with FQL, for some friend, I can retreive all the data needed but with someone other, I get an empty object as response, this is the query:
SELECT post_id FROM stream WHERE source_id=friendID
Knowing that I can actually see the friendID's posts through facebook, I tryed, to get the data through the api, adding a field in whitch use my id as id of the user who is asking for the data
SELECT post_id FROM stream WHERE source_id=friendID AND viewer_id=me()
I also tried this method, advised to me by another user:
SELECT post_id FROM stream WHERE actor_id=friendID AND source_id=me()
None of what i tried works, so, my questions are:
-This friend should grant me access to his data through the api? And how?
-There is an hack to bypass this problem?
-There is a way to understand if the user have 0 posts or I can't see his posts?
Thank you
Actually the problem is that your friend is not allowing apps to bring his info while you can see those data through your facebook account.
Why?
Go to Account Settings then go to Apps settings then select the option Apps other use.
just click here to directly open those settings https://www.facebook.com/settings?tab=applications&section=friends_share&view
You will see a list of categories and most of them are checked (See image below)... so if your friend unchecked the options that he doesn't want apps to access then you will not be able to access the info using an app while, as I said before, you can see these info from your Facebook account.
There is no solution for this because it's a privacy setting your friend prefer...
Note: if your friend added your app then app permissions will override the categories that don't permit the access of apps then queries will return info.
You can check it yourself. Create a temp facebook account and try changing those options and query the stream of your temp account with your main FB account. you will figure it out...

Facebook Graph Api json missing posts

I am developing an web app, which connect to facebook, to get posts, and other stuff liked by users. I have problem with getting all posts from user page using news feed(home connection of Grap API).
When getting access token in my app for user, I ask for read_stream, user_activities and offline access permissions. Then, when I use that token, to get json feed for
https://graph.facebook.com/me/home/?access_token=<retrived_access_token>
some posts(which are show on user page) are missing. I found that posts of my friends, which can be seen only by their friends, are not shown in that feed. The same issue is with posts of users which current I am subscribing.
I was searching on that for a while, and I found, that when I use link from http://developers.facebook.com/docs/reference/api/ to get my news feed, there are much more posts. It's seems to use a token generated for test console app for facebook api.
Then I tried to generate access token which would give me similar results using http://developers.facebook.com/tools/explorer?method=GET. But even when I give to generated token all possible permissions I could not get it working good, there were still some missing posts.
I read answer in that post, Facebook graph API does not return all posts for user, which suggested, that this is because of permissions set by my people who publish posts, who don't want their data to be retrieved by an app. I run some quick test, and I found that changing that setting is working( when somebody change that setting her posts will disappear from both feeds - that using my app token for user, and that under link on api reference page), but it's not the case.
It seems that this token generated on api reference page have an special permission.
I really need to get as much posts from user page as possible. I know that I will not get those blocked by their author, but as many of my users subscribe other users I really need to get access to kind of posts shown on user page.
I also read Facebook graph API: feeds missing in json response but it was also not helpfull.
I will really appreciate any help.
It is impossible to get a full list of posts from the feed / home Graph API, but you can use FQL to query the stream table to get almost every post made by friends, here is a quick example of how you would do that with the javascript sdk:
var query = 'SELECT post_id FROM stream WHERE filter_key = "others"';
FB.api('fql', {'q': query}, function(posts) { console.log(posts.data); });
This will get you the post ids, which you can then use with graph api to fetch the rest of the post info. Or you can get the full list of fields here, you can't select * in FQL so you'll have to list each piece you want and then get comments and likes and names separately.
There is an assigned/medium bug on this at http://developers.facebook.com/bugs/228057243915183. You can bump up the priority by subscribing and indicating you can reproduce it.
Also see http://developers.facebook.com/bugs/231621496918030 where Facebook has said "the stream table and me/graph have limitations. See the documentation for more info. We're trying to make this more clear in the future." Personally I don't think there is really any more info in the documentation though.