How can the insights edge be used on the /<page_id>/posts URL with the Facebook Graph API - facebook

So I am trying to retrieve some insights information and noticed there was a connection within the posts field of a page. When I use this connection, it retrieves all of the insights information, all metrics. I only want to limit myself to a few that I need, instead of getting the overhead of searching it out myself after I pick it up.
This is the URL I have tried to limit myself to only the post_consumptions metric
https://graph.facebook.com/v2.0/<page_id>/posts?fields=insights{post_consumptions}
This doesn't work, it still returns every metric, so I thought maybe I can't choose the metric, but only the fields. Then I tried this:
https://graph.facebook.com/v2.0/<page_id>/posts?fields=insights{id, name}
But there were no changes in results, I can't seem to find any documentation about this connection either in the documentation of Facebook Graph API, which doesn't really surprise me as Facebook does this quite a lot.
The documentation about it, which I could find, are here:
https://developers.facebook.com/docs/graph-api/reference/v2.0/insights
https://developers.facebook.com/docs/graph-api/reference/v2.0/post#edges

I dont know if you still have this problem but i solved it like this
https://graph.facebook.com/v2.2/<page_id>/posts?fields=insights.metric(post_impressions_unique)

Related

No next url for getting instagram medias on facebook's graph API for business accounts

I am trying to fetch all of my instagram page's posts (around 57k posts) from facebook's graph API. using the 'media' endpoint described here:
https://developers.facebook.com/docs/instagram-api/getting-started
I have managed to get around 12k posts using it using the query below:
https://graph.facebook.com/v3.3/{ig-user-id}/media?access_token=XXX&pretty=0&fields=timestamp,caption,comments_count,like_count,media_type,media_url,owner,permalink,shortcode,thumbnail_url,username&limit=200
when using this link returning result contains a data part which is for posts' data and a pagination section which includes next and previous urls and cursors for after and before. I used next and got remaining posts each time, until the result didn't have a next url but it had an after cursor but when I used it the data returned was empty.
I thought there might be some kind of limitation, but couldn't find anything so far except for the API rate limits which I don't exceed.
I also tried the graph API explorer and got the same result.
The problem was not solved but I found something I hadn't seen before, it might help people confused like me.
in the endpoint documentation it is declared that this endpoint has a 10k recent posts limitation, therefor we cannot get any more of our posts.

Difference in Engaged Users (Facebook page) and Engaged Users (Insights API)

We have a tool connecting with the Facebook Insights API to grab various metrics (Likes, Comments, etc).
One such metric is the Lifetime Engaged Users.
However, we've looked at many FB pages (not going through the API) and the insights numbers seem to be different.
I have used the Graph Explorer to check if there is an error in our request, and this is not the case. For example, in one case, the call returns "13480".
Here is the screenshot from the Insights page:
FB Insights Page
I may not be checking at the correct numbers, but can someone help me out?
I would like to figure out how I can find this particular metric, other than using our tool or using the Graph Explorer.
Thank you!
Try this: go recheck your call to API, remove that S from "metricS=metricName".
I met this problem today, and find that there are two ways to get object insight data:
object-id/insights/metricNameA,metricNameB
object-id/insights/?metric=metricNameA,metricNameB
I happened to use the 2nd way, and wrongly typed metricS instead of metric, which led to return an array of data for all metrics, and my code data[0].values[0].value therefore got the first metric in that array which is "post_story_adds_unique", if you have same mistake as mine, that 13480 could be this 1st metric return by default from FB.

How to get all user's likes using facebook's graph API

How can I query facebook's graph API to retrieve all user's likes (not only pages but also photos and others)?
For instance, how could I get all the pictures a user has liked? Using facebook's search bar you can find them easily by clicking on "photos has liked".
I wrote a script that scrapes the page content and does that but it's not very efficient.
I have recently come accross a similar problem, maybe this helps you solve it.
https://graph.facebook.com/v2.5/{page_id}/feed?fields=likes.limit(1).summary(true)&since={start_date}&until={end_date}&access_token={access_token}
This will give you a list of all posts that received likes during the specified time period. If you manage to write a code summing up the following JSON path you got your sum for "all user's likes":
data[0].likes.summary.total_count
Not entirely sure is this is exactly what you were searching for, hope it helps you though - and if not you, someone else.
As for likes you can also use the same way to extract Shares and Comments:
Shares
https://graph.facebook.com/v2.5/{page_id}/feed?fields=shares&since={start_date}&until={end_date}&access_token=
Comments
https://graph.facebook.com/v2.5/{page_id}/feed?fields=comments.limit(1).summary(true)&since={start_date}&until={end_date}&access_token=
Best regards
There isn't to my knowledge any way to get this from the API without grabbing every type of response from the API and then sorting through for likes. Facebook search bar uses an internal API different from the Graph API.

Final Checklist/Written Approval for Facebook Graph Use

i am using this endpoint
https://api.facebook.com/method/links.getStats?urls=
to collect the number of likes of specific urls. I want to display this information on a front end but do not want to make unnecessary API calls (there are over 25,000 posts). I would like to retrieve this information and store it so it can be retrieved from our database. On some pages, there will be over 10 of these accessible view a hover effect from a mouse. I would prefer to not have to load the page up with javascript targeted elements everywhere. It would be much easier to have the information stored and updated periodically. We will not be going over the impression limit or even coming close, but I would like to just make sure I'm not doing anything that will get me in trouble.
I would like permission to utilize this data to help increase pathways between our site and Facebook to allow people to share the page. I'm pretty sure we're doing everything correct but would just like to make sure and not step on anyone's toes.
I read through the checklist here
https://developers.facebook.com/docs/opengraph/submission-process/
however I don't know if what I'm doing would be considered an app....? Any advice would be appreciated.
Have a look at my answer here: How do I get the likes number from facebook for a given url?
You can also use FQL queries with IN lists to query multiple URLs at once. Please consider that a FQL statement can have a maximum length of 2048 characters.
select url, like_count from link_stat where url in ('URL1', 'URL2', ...)
The "cheklist" you linked is completely unneccessary, because you don't need to submit anything related to OpenGraph objects or actions. You can even use the functionality without using an Access Token, because the link_stat table is public (https://developers.facebook.com/docs/reference/fql/link_stat/)

Retrieve group events with Facebook Graph API

I'm a little confused trying to adapt to the new facebook Graph API.
Whereas before I would have used events.get, I'm not entirely sure what to use now!
I can't seem to get a list of a group's events through fql, nor through the Graph API itself.
Any pointers? Should I keep using REST?
In the documentation under "Connections" it doesn't appear that you can get /events. Or for that matter /albums or anything useful...
http://developers.facebook.com/docs/reference/api/group
However, if you know that something is an event (which you could probably do because the link in the data has "eid" in it - I can't see a way beyond that) then you can call the event URL (http://developers.facebook.com/docs/reference/api/event) and get the details that way.