I would like an efficient way to get total likes for every post for a given facebook page. To get the total shares, I can submit the following request to the API:
https://graph.facebook.com/<page>/posts?fields=shares
and get back a list of total number of shares per post. However, when I try to do the same with likes:
https://graph.facebook.com/<page>/posts?fields=likes
I get a list of users who have liked that post, capped at 25. To get the total number of likes I would have to traverse the list for each post, which would be rather impractical. Is there any way to get the information in the same format as for shares?
The above can be accomplished with:
https://graph.facebook.com/<page>/posts?fields=likes.summary(true)
Which will still fetch pages of people who liked the post but will also have an additional summary field showing the total count.
Related
I would like to query earliest posts of a Facebook user using FQL or Graph API. The big issue is by default, Facebook limit return items, which are ordered by descending time.
I know I can limit my query by until, but I don't know what date to put in, because I have no idea when my user become Facebook member. I have to do search like:
find post until Jan 2006
if null, then find post until Jan 2007
if null, then find post until Jan 2008
....
which I hate so much.
Is there a smarter way to find out earliest posts by user?
First off, it's near impossible to have an all encompassing program that determines when a user joined Facebook, to put it quite bluntly. I know from your past questions, you have been trying but many have tried before you, it's not possible.
For example what happens if no one decides to write anything on my wall from the date I joined to 1 year after? That indicator becomes pretty inaccurate now does it?
Anything smarter is based on assumptions that may or may not hold true.
e.g.
Assumption 1: Every Facebook user would publish a post on or near when they joined
this give an initial guess based on A1
Assumptions 2: Given A1, any post by a friend on a user's wall that is posted before the unix time returned by A1 will be earlier in date
this will always be true as long as A1 holds.
All of this falls when there is a year between actual activity and join date.
You can minimize the set returned by calling less data per item and more items overall
/me/feed?fields=created_time&limit=200
Then you page until there is no next paging parameter left.
If you are indeed trying to find when did a user join Facebook, I agree with phwd's answer.
The best way I have been able to find out (which is also cheaper than having to reiterate through tons of posts) is accessing the earliest "profile pictures" of the user. This is making the assumption that a user would post a profile picture soon after creating their account.
Once you can get access to "Profile Pictures" album, you might be able to use created_time field for the album (or sort Profile Pictures by created_time for individual photos).
Even if the earliest photo was deleted, what are the chances that the user stays without any profile picture for a long time?
Reference:
https://developers.facebook.com/docs/graph-api/reference/v2.0/album
Using the Graph API or FQL, is there a way to efficiently find a user's first post or status? As in, the first one they ever made?
The slow way, I assume, would be to paginate through the feed, but for users like me who joined in 2005 or earlier, that would take a very long time with a huge amount of API calls.
From what I have found, we cannot obtain the date the user registered with Facebook for a good starting point, and we cannot sort by date ascending (not outside of the single page of data returned) to get the oldest post on top.
Is there any reasonable way to do this?
you can use facebook query language (FQL) to get first post information.
Please refer below query for more details :-
SELECT message, time FROM status WHERE uid= me() ORDER BY time ASC LIMIT 1
Please check and let me know in case of any issue.
Thanks and Regards
Durgaprasad
I think the Public API is limited to the depth of information it is allowed to query. Facebook probably put in these constraints for performance and cost concerns. Maybe they've changed it. When I tried to go backwards thru a person's stream about 4 months ago, there seemed to be a limit as to how far back I could go. Maybe it's a time limit or a # posts back limit. If you know when your user first posted, then getting to it should be fairly quick using the since/until time stamps in your queries.
In order to go through all notes of a user I first want to know the total number available. The only way I found so far is to get them all by setting the limit to a high enough value - but this is pretty slow since all note objects will be fetched including their content. There must be a more effective way since the normal public https://www.facebook.com/<user>?sk=notes page displays the total at the bottom line very quick.
You can't get only number of notes without fetching the details for all of 'em.
You can however speed the query by limiting fields retrieved by adding fields argument to notes connection URL:
http://graph.facebook.com/me/notes?fields=id&access_token=...
This will only return ids of notes without all the rest of details (which should be faster that retrieval of all notes data).
I know how to get the number of people who like a given page, what I'm looking for is how to get the count of people who like two specific pages. That is, can I get the number of people who like the pages (for example) Lady Gaga and Oreos? You can get the count for each very easily, but is there a way to figure out the number of people that overlap and like both? Not looking for the names or profiles, just the total count.
No. For privacy you can't get the list of Uids for each page's likes - so there is nothing to compare as you would need a list of Uids from both pages and then see which Uid's are in both lists.
See this post for more detail: How to list facebook users who like a page or interest
You can get the number of likes for a page via the Graph API Explorer. However, doing data mining like finding out the count of the number of people who overlap between the two pages is not released by Facebook. They get a lot of income from selling data points like that, so they're not going to let that cash cow out of their corrals.
I'm seeing a discrepancy between the number of likes reported in the Graph API vs the number of entries in the "data" that has the name and ID of the people who liked a post.
When I view a certain post on Facebook, I see that it has 5 people who have liked it.
When I use the Graph API to fetch the post, the "likes" field has a "data" field with 3 entries in it, and a "count" field whose value is 5.
When I use the Graph API to fetch the likes for the post (eg, {post_id}/likes), I get a "data" field with 5 entries in it (and no "count" field).
Clearly the true answer to how many people have liked the post is 5. But then why is there only 3 entries in the "data" when I fetch the post object?
Here's another example of the same discrepancy:
https://graph.facebook.com/40796308305_10150394134258306 returns data for a post whose "likes/data" only has 1 entry in it, but whose "likes/count" says that there are 3. But https://graph.facebook.com/40796308305_10150394134258306/likes returns "data" with 3 entries. Finding that same entry on Coca-Cola's page finds that there are, in fact, 3 people who have liked it.
The documentation of the post object doesn't mention that the likes list may be incomplete, and the documentation of the fql stream table explicitly says to use the post object to get the full list, so It's either a bug in the API or in the documentation.
I suspect it may be a deliberate but undesirable "feature" to limit the detailed list for performance reasons, as some posts may have hundreds or even thousands of likes.
It ends up actually causing a huge performance problem as I need to find all posts that have been liked by a particular user, and the only way to do that is to do a separate fetch of likes for each post in the list whose like count is higher than the like list length.
2 people have their privacy settings set to not show their name to people who are not their friends.