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.
Related
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.
I'm trying to analize a large number of posts from varoius pages for my bachelor thesis. Therefore I'm using a tool called Facepager which uses the graph API to fetch data from Facebook.
I need the following data:
id, link, type, from and the count of likes, shares and comments (just the numbers, no further info!). In general, everything is working just fine, only posts classified type=status behave strangely. For some of these posts, there is no data shown about like, share and comment counts, further more there is no link given. But as mentioned before, this only happens sometimes! I searched for the affected posts manually on facebook and some of them had a large number of likes, shares or comments.
I also tried to fetch data with graph API explorer with similar results.
Is there any reason why it isn't possible to get share, like and comment count on some of the posts classified type=status?
Additionally, I'm planning to use the ID or if invalid, the link to open specific posts in my browser. This is not possible for some of the status posts either.
Sorry for that newbie question, it would be amazing if I could get an answer because at the moment I am quite desperate because this is really important for my bachelor thesis. Thanks a lot!
Because this kind of post is a post which "CAN NOT BE VIEWED".
ex: "xxxx likes a link", or "XXX commented on a post".
I suggest that you should filter out these posts by yourself.
I have an idea to create a "top posts" feature to my website, which creates the "top" list depending on how many likes and shares that a post have on facebook.
Users may see how many likes an post has received so far since they only have to ask for a single, defined url. However, the website itself has to be able to query all the links that are tied to itself (which have a predefined url template like website.com/[post-id]) to create the "top" list. Is it possible to do something similar (or achieve the same result in a different way)?
Any ideas on a real workflow about something like this will be appreciated!
this seems like a little but interesting project. I don't know if there is a feature that could get that directly in the way you want, but i did something similar.
First you have the Graph API, with that you can get the Posts of a user using feed, with that every post is telling you how many likes does it have which you can get with POST_ID/likes.
Then you'll have to check for changes in the post periodically comparing its created_time and updated_time.
This could seem very hard, because you have a lot of posts and you have to check them all for updates, but you can use batch_requests so you can check them all at once.
I have made a bookmarklet which shows top posts in the Facebook News Feed as well as Google+, Twitter and Instagram Profiles.
Just add a new bookmark in your bookmarks bar and replace its URL with the following code and save it, then go to the social network website and run it:
javascript:(function(){var s=document.createElement('script');s.src='https://niutech.github.io/topnewsfeed/topnewsfeed.min.js';document.body.appendChild(s);})()
The source code is available on GitHub.
I'm experimenting with the Graph API, specifically the News Feed query (me/home). And right off the bat, I can see that the JSON returned does not match what I see on my own facebook page. The API returns some objects that are not on the page, and vice versa. I can't figure out what's going on here. I don't think it's about people I've unsubscribed from or anything like that.
Is this expected behavior, or am I doing something wrong? Is there documentation somewhere that explains what the difference is?
edit 22-Nov-11: this is never going to be answered, is it.
NewsFeed via api ordered by time but on facebook.com ordered by top stories
Open your recent news feed > https://www.facebook.com/?sk=h_chr
you will find that it's the same as api (y)
When I type name of e.g. youtube clip in facebook search I can get number of people that share this link.
Is it posibble to fetch list of people sharing given like using facebook api?
No, you can't get who shared, only the total number. The easiest way to see the count is, for instance:
http://graph.facebook.com/http://stackoverflow.com
This solved my problem !
http://graph.facebook.com/http://stackoverflow.com
Creating Facebook apps was very easy, but now, you need to apply and ask for approval the app ... that sucks ...
You can do this with Facebook's FQL (Facebook Query Language), it gives you more information than the previously mentioned Graph API method, but Facebook are apparently going to turn off the FQL API on August 7, 2016. So its not going to be useful in the long term.
https://api.facebook.com/method/fql.query?query=select+comment_count%2C+like_count%2C+total_count%2C+share_count%2C+click_count+from+link_stat+where+url%3D%27stackoverflow.com%27
The interesting thing about this is it shows the result given by the previously mentioned Facebook Graph API request, i.e:
http://graph.facebook.com/http://stackoverflow.com
is actually giving the "total count", which is actually the sum of the likes, comments and shares of that link, the FQL method gives you the actual individual counts for comments, shares and likes.
Another method for getting the actual share count, is to use the links.getStats API call, but it appears to be undocumented, and nobody seems to know how long it will be available for.
Here's how to use it:
https://api.facebook.com/method/links.getStats?urls=stackoverflow.com&format=json