graph api returns empty data array when requested post_id/reactions - facebook

I am trying to get all the reactions of a facebook post with post_id/reactions in Graph API. But the returned data array is always empty. I have generated the access token with all the user data permissions. I am attaching a screenshot of the scenario.
Does this problem has something to do with some more permission?
EDIT:
I also found out that this post_id/reactions is only showing the data of my reactions of a post. So, if I react on a post and do a graph api query for that post, it will show my information only. Does anybody know the reason/solution for this? Attaching the scenario.
EDIT 2:
I followed a youtube tutorial to do it like this. But apparently, it cannot be done (at least with this way!). It is mentioned in the documentation (screenshot attached).
If anybody can still provide me any other way to do this, please mention.

You can view the reaction of the user if you have his access token. This with:
{post-id}/?fields=reactions.type(LIKE).limit(0).summary(1)
The returned field "viewer_reaction" is the reaction of the user in the post.

Related

FB graph API get post comments by given user

Do you know if its possible to get the list of post comments by given user?
I tried this: <post_id>/comments?fields=from.id(<user_id>) but it still returns array of all post comments. I think I have enabled all the permissions because I can see the from field but it looks like 1) the filter is not working, 2) I am doing it wrong. The graph API version I am using is v9.0
My goal is to get list of comments by given user or receive an empty array if the user didnt comment the post. Maybe there is a different way how to do it..
You cannot do this by calling the graph api anymore :/
But, there is some kind of workaround you may be able to do.
First, you'll have to set a page webhook to retrieve all the comments written on your page. Find the documentation here: https://developers.facebook.com/docs/pages/realtime
The information sent to your server via the new comment's webhook contains the "from" data, looking like this:
{
name: "Foo Bar", // the user's name
id: "12345" // A user ID (unique for your page. Will be different for the same user accross 2 different pages)
}
You may then be able to pick only the wanted user's comment
I clearly see 3 downsides to this workaround:
It only works with pages
You need to handle in realtime all the comments written on your page
You cannot retrieve the comments posted in the past

Get restaurant menu from Page using Facebook Graph API

The problem is to get the link to menu from a Facebook official page of a restaurant.
Here is an example of such page: https://www.facebook.com/freshchoice.bb — there is a link to menu of the restaurant which leads to https://www.facebook.com/download/216155385221332/Facebook%20menu.pdf.
Actually, this link works well even if I remove the name of the file from it, and I understand, that 216155385221332 is an ID of some object. But how can I obtain this ID from the API?
I have already spent two days trying to find a solution for this task and have had no luck.
When I request data from Facebook Graph API, I get tons of information, and I can request any of the fields listed here: https://developers.facebook.com/docs/graph-api/reference/page but there is no 'menu', or 'downloads' field, and I have almost broke my brain trying to find out a way to solve this puzzle.
I don't think there's a way to reach this object if you didn't create it yourself.
There's the restaurant.menu OpenGraph object:
https://developers.facebook.com/docs/reference/opengraph/object-type/restaurant.menu/
but I think only the user who created it can access it programatically.
The page you're referring to probably just uploaded the menu via the Facebook website, and didn't create an OpenGraph object.
Se
https://www.facebook.com/help/533179700126832

Facebook Graph API: Get post/status attached photos

How can one get multiple attachments of a post/status in a group?
For example: A group status that some member wrote and added multiple photos to..
Currently I am using Graph api to get the group stream with group_id/feed and unable to see images attached to a single status - while accessing the feed from Facebook itself I can validate that there are few photos attached to the status.
Using FQL it is possible to get the attachments with the following query:
SELECT attachment FROM stream WHERE post_id = each_post_id
Considering I will have to send this request per post and that FQL will soon be gone I am searching for an alternative.
I was looking for a solution for this as well and actually just found it.
The Facebook Platform changelog says the following:
/v2.1/{post-id} will now return all photos attached to the post: In
previous versions of the API only the first photo was returned with a
post. This removes the need to use FQL to get all a post's photos.
With this knowledge I went to the Graph Api Explorer and found a post that had 2 attachments or more added to it.
After finding the post, and with that the post id, I tried the request Facebook told me to do:
/v2.1/{post_id}
This does NOT give you the desired result. The nice thing about the explorer is that you can search for fields you want to add to your request.
You want to add the attachments (plural) field. NOTE: It might be that the graph api explorer only shows the attachment (singular) field. This is NOT right.
So, to summarize:
Get the post id of the post containing the images.
Create a new request to the graph api that looks something like: /v2.1/{post_id}?fields=attachments
Then read the result to get your desired attachments.
I hope this helps you out as I have been struggling for a while as well.
KR
PS: This is tested with a user and not a group, but it should be basically the same.
PS2: This is just an explanation of how you get attachments of a single post. You can also add the attachments field to the /me/home egde to immediately get all attachments at every post like so:
me/home?fields=message,from,attachments
PS3: The permissions you need are
user_status
read_stream
user_photos
user_videos
Facebook is not very clear on this matter and it is very hard to figure things out like this. So I hope this will help everyone that is searching for this solution.
I answered for the same question here : /v2.1/{post-id} does not deliver photos
It seems it's a Facebook bug. My colleague opened an issue. Here's the link: https://developers.facebook.com/bugs/762280800482269/
You also can find some info here:
https://developers.facebook.com/bugs/790976317600139/
Hope it will help you.

Facebook Insights about post

I am trying to retrieve metrics post_impressions_unique, post_consumptions or anything started with a post but Facebook always return empty array for me.
Anyone know what is the problem here?
Are you sure you have the right permissions?
You need read_insight permissions to view post impressions using fql or the graph api.
Here is more information Facebook Developer Guide
As well as needing the read_insights permission, this information is only available for posts made by your page, so check you're actually checking the right posts
Make sure you pass in the entire object ID of the post. It will be of the format pageid_postid (eg. 24379523495_8924592457245) and you need to quote it in single quotes - otherwise you'll get an error about an unexpected underscore.

facebook graph api does not return all feed items on facebook page

at the time of this question, if you go here:
http://www.facebook.com/realplayer
you'll see six posts down, I have posted a photo with a message of "#highfive Cincinnati, OH"
but if you to either of these:
http://graph.facebook.com/realplayer/feed
http://graph.facebook.com/realplayer/tagged
the JSON that is returned seemingly includes everything on the wall, except for MY post. there is another photo post from someone else down below mine, and it is showing up (and both my photo and his photo are in the "Fan photos" section)
obviously, since I can see everything with these links already, it appears that access_token is not a part of the equation... BUT, some more info:
if I use an access_token from a session that isn't me, I can't see the post in the JSON
if I use an access_token from MY logged in session, then I DO see the post in the JSON
so I'm very confused.
if everyone in the world can see those posts on the wall without even authenticating, then I expect all of them to come back in the graph api as well.
anyone have thoughts on this?
I am aware of the "manage_page" permission... which I can use to get a list of accounts and special offline access tokens for those pages... and that's something I can explore... but it seems like alot of work when my post seemingly SHOULD be there in the graph
well looks like FB has this nice little anti-spam feature for pages... such that a non-admin can't write lots of messages on your page. what's interesting is that facebook uses similar "silent treatment" techniques that StackOverflow uses ( https://blog.stackoverflow.com/2008/09/podcast-21/ )... so when I look at a wall that I've been "spamming" I will see all of my posts... but no one else will.
I was able to create a new test account and get about 3 or 4 messages on a page before it started blocking me again
so probably the Graph API is working as designed :)
========================
UPDATE: this appears to only be part of the problem. I have constructed another page and app and been doing testing:
http://www.facebook.com/pages/RP-Test-Page/116735865065591
note the entry for "#highfive Orlando, FL" ... even an unauthenticated user can see this entry from the actual page... but there is seemingly no way for me to get it back through the API. He only posted once, so it can't be an "anti-spam" thing (you wouldn't think).
I have obviously tried the Graph API (with and without my own access token)
I have tried FQL (with and without my own access token)
and I have followed this post:
http://en-gb.facebook.com/topic.php?uid=10381469571&topic=3815&post=51980
in order to request manage_pages and offline_access extended permissions from myself and use that to get the /me/accounts and then get the "impersonation" access token (whew)... STILL NOTHING
there must be some other super security thing going on. is it not possible to reliably get all of the wall posts from a page?