Facebook Graph API does not give any data earlier than 2011? - facebook

I'm the author of Fazzle app on iPhone. What my app does is basically download user status updates and sort them in various orders (e.g. most liked, most commented).
I have been wondering if Facebook allow developers to get user's status updates since the day they joined Facebook, because when I launched the app I can only get user statuses from 2009. Today I just discovered that Facebook limits Graph API calls down to just since 2011.
I tried looking at documentations, asked around here, and contacted Facebook through their forum. However so far there is no word on this limitation in Graph API. Did I miss something? Is there any other way for me to get data for status updates earlier than 2011?
You can test it yourself here. Use this GET request:
https://graph.facebook.com/(your_user_id)/statuses?limit=99999
Scroll down and you'll find out that not everything's downloaded.
Is this because of conflict of interest with Facebook Timeline? If so, that sucks.
Logged as a bug here. Still hoping someone can point out my mistakes if there's any.

Absolutely you can get older posts from Graph API; there is no limit (at least not that I am aware of). Use the since and until parameters to page back through results, instead of offset:
https://graph.facebook.com/me/feed?access_token=[token]&until=1165474447
Documentation for Paging doesn't go very in-depth on since and until:
When querying connections, there are several useful parameters that enable you to filter and page through connection data:
limit, offset: https://graph.facebook.com/me/likes?limit=3`
until, since (a unix timestamp or any date accepted by strtotime):
https://graph.facebook.com/search?until=yesterday&q=orange
But basically, until is like saying "Give me posts up until this date", and since is similar, "Give me posts since this date". So you can scroll all the way back through a user's feed using a loop something like this:
// pseudocode
timestamp = now
do {
posts = graph.get(/me/feed?until=timestamp)
if posts.length == 0: break;
// process posts
timestamp = posts[0].created_time // first should be the oldest, in theory
} while (1)
Replace until with since and oldest created_time with the newest to go forwards in time, e.g. to grab any newer posts since the last time the user ran the app.

Facebook has since confirmed this as a bug. If you have followed Facebook's bug tracker ever, unfortunately that means there is very little if any chance they will actually fix this.

You will need to paginate. Limit is limited. Please read http://developers.facebook.com/blog/post/478/

Related

Facebook Graph API always returns 0 as count for CARE reaction

I am collecting reactions for Facebook posts on public pages. This works for the classic reactions (like, haha, angry, ...). However, Facebook at times also offered reactions such as thankful, pride, or currently care.
According to the documentation (https://developers.facebook.com/docs/graph-api/reference/v3.2/object/reactions) something like this should work (also in older versions of the API such as 3.2 which I am using):
16673188972_10160314322883973?fields=
reactions.type(LIKE).limit(0).summary(true).as(like),
reactions.type(LOVE).limit(0).summary(true).as(love),
reactions.type(HAHA).limit(0).summary(true).as(haha),
reactions.type(CARE).limit(0).summary(true).as(care),
reactions.type(THANKFUL).limit(0).summary(true).as(thankful)
For a (random) post with ID 16673188972_10160314322883973 found here https://www.facebook.com/JennyLewis/posts/10160314322883973 it returns the correct number for likes (812), for love (346), for haha (1), but not for care. I get 0 for care reactions, although there are at this point 15 care reactions for this post. I have tested this with a few posts that have care reactions and care reactions are always 0 (as are thankful and pride reactions which are not available at the time—however, I did not look up posts with these reactions to them). Has anyone experienced the same thing (or managed to get correct CARE reactions through the Facebook API)?
Here the post:
FB post
Here my API testing call:
Graph API test
EDIT: Added "limit(0)" to reflect my real API call. This did not change anything. I also ran the same thing now on one of my own posts with API version 7.0. Same result. However, I recognized that the "special" reaction CARE was counted as a regular like. So maybe there is no possibility to capture the number of CARE reactions?
There are currently two bug reports pending:
https://developers.facebook.com/support/bugs/236778101089217/
https://developers.facebook.com/support/bugs/686426458757119/?locale=en_US
It exactly matched my description and was reproduced and assigned to developers by Facebook. So maybe, this will be fixed soon.
Sorry for not checking Facebook bug reports earlier. I will update this answer if the problem gets fixed.
UPDATE [2020-07-03]: Apparently, this behavior is by design (see links to the bug reports above). Facebook won't change it. Temporary reactions will be subsumed under "likes". So there will be no "fix". Temporary reactions such as "care" are counted as likes.

Facebook API get new comments to posts

I am using Facebook4j to access the Facebook API for a Page.
I can get a list of new posts for a Page, using
connection.getFeed()
and get the comments for a Post using:
post.getComments()
But I also want to be able to get new comments to the page posts (while ignoring comments that I've already fetched).
Any idea of how to do this, other than searching through the comments of every post all over again?
There is no way of doing it with the current Facebook4j API.
If you look at the list of the unsupported features on their page you will see:
Application APIs -Application - Facebook Developers
Ads APIs - Ads on the Graph API - Facebook Developers
Real-time Updates -Realtime Updates - Facebook Developers
Field Expansion - Field Expansion - Facebook Developers
Open Graph API - Open Graph - Facebook Developers
What you are looking for is real-time updates for the new comments.
You can take a look at this guide about subscribing to real-time updates.
If you'll look at the real-time updates link i provided above you will notice that real-time updates are limited to certain types of objects and a subset of their fields which are also listed there.
The valid types of objects for subscriptions available are the user and page Graph API object (with the feed field amongst others).
The real-time updates only indicate that a particular field has changed, they do not include the value of those fields. So this only makes apps more efficient, as they know exactly when a change has happened, and don't need to rely on continuous or even periodic Graph API requests when changes aren't happening.
You will know which field of the object (either user/page/permissions/payments) has changed, in your case the feed.
But other than that you will have to go through all the posts that you are interested in and the comments - though you could probably do it efficiently. For this you can probably keep your Facebook4j API code which gets the feed and recall it on upon updates. Or better yet upgrade the code to only track the changes you want and so on.
There is this example here (SO) on how to get facebook real time update in java. You'll get the point and probably build something better.
This answer suggests using Spring Social Facebook as it has a real-time update controller for handling real-time update callbacks from Facebook , whereas RestFB and Facebook4j can't do that.
To answer the question, if Facebook4j supports this, no, it does not.
This isn't done easily with the official graph API either, as comments use cursor based pagination; so filters like since and until will not work (they will work on things like feed though. (Source)
In order to do what you want, you would need to get all comments from now until the time you last got them. You can have comments returned ordered (most recent first, to oldest last) by using ?filter=stream
You can execute a raw fb request via fb4j for this:
// GET
Map<String, String> params = new HashMap<String, String>();
params.put("filter", "stream"); //add the ?filter=stream
//res will be the RAW response
RawAPIResponse res = facebook.callGetAPI("POST_ID/comments");
//you can get it as a JSONObj with:
JSONObject jsonObject = actual.asJSONObject();
OR, to do it without a raw request, you can use comment.getCreatedTime() to get the time for each comment, and then filter the old ones out.
Either way, you'll have to filter them yourself, as neither facebook4j nor the graph API support this natively.

Get a page's average number of posts / day using Facebook API?

I'm trying to figure out a way to calculate a Facebook page's average number of posts per day using the API. The problem is that the API does not show when the page was created. Instead, I'm downloading all the posts and using the oldest post as some sort of creation date (which is not 100 percent correct...).
The problem is when a page adds backdated posts. For instance, someone might post a picture in 2012 that's dated 2008. Then that post will be oldest, even if the page hasn't existed that long.
One solution is to go by the updated_time field instead of created_time, but it's not a great solution that still may not be correct.
Is there someway to get around this?
Sorry if this question has come up before, but I couldn't find anything on it.
Unfortunately what you're looking for isn't possible using the API.
For a given post two dates are returned - created_time and updated_time.
As you rightly pointed out the created_time can be updated to add a post in the past.
updated_time also will not work for you as this gets updated whenever someone comments on a post.
https://developers.facebook.com/docs/graph-api/reference/v2.3/post

Using Facebook Graph API, how can i get past events for my page?

Currently I can see all upcoming events:
https://graph.facebook.com/page-id/events?access_token=...
Setting the 'since' parameter to 0 does not show past events.
If anyone has successfully fetched past events through the Graph API please share.
There is an unfixed bug in the facebook graph API preventing the user from retrieving past events from pages that are not his.
In fact the only solution is to use some FQL like this:
SELECT eid, name, description, start_time FROM event WHERE creator = [pageid]
The since parameter takes a date as the value in a specific format. For example 2012-08-17T16:20:00-0500. See https://developers.facebook.com/docs/reference/api/dates/ for details on formats.
One thing of note is there seems to be a limit on how far back the API will go in returning the events but I am not sure what this is yet.

Get my wall updates

I'm trying to get the recent wall entries for my wall, so the url for this is dead simple:
https://graph.facebook.com/me/feed?limit=30&date_format=U&since=1308733229&access_token=<token>
Now, i'm just putting current time in place of since= and getting recent entries
But, the problem is, if something gets updated (someone comments my wall entry) it won't show up as something new
Is there any proper way to get new/recent comments OR to get updated wall entries? (fql may work too)
You can use FQL to get a little more control over what you are returning from your feed, check out https://developers.facebook.com/docs/reference/fql/stream/
How do you define new? As in content since the last time you polled the API? You could do this on your end by getting the difference between what you already have and the result of your latest poll.
Or if you would prefer pushed updates that only include the differences since your last update you can subscribe to the realtime updates API: https://developers.facebook.com/docs/reference/api/realtime/