I am trying to fetch Newsfeed using the Facebook (API) FQL.
In an attempt to page results, I was initially using LIMIT and OFFSET parameters like this:
SELECT post_id,.... FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid = me() AND type = 'newsfeed') AND is_hidden = 0 LIMIT 20 OFFSET 0
And then every time, I hit the end of the ListView
, I run another query and fetch the next set of Feeds by incrementing the OFFSET by +20. I took the logic from this answer: https://stackoverflow.com/a/13265776/450534
However, the problem is, LIMIT and OFFSET parameters don't necessarily give you all the results and searching on SO revealed that Facebook recommends using time constraints.
Now I need to modify the code so that Feeds are fetched for each day. For example:
Initial Set Of Data - `created_time < 1355788800` (17th December)
Second Set Of Data - `created_time < 1355702400` (16th December)
Third Set Of Data - `created_time < 1355616000` (15th December)
.
.
.
.
After searching a bit, getting a solution to convert current time into a Unix TimeStamp was achieved like this:
Date now = new Date();
long unixTime = new Long(now.getTime()/1000);
But, for every new set of data, how do I decrease the Date
by 1? I tried this piece of code:
Calendar newCal = Calendar.getInstance();
Calendar xDate = (Calendar) newCal.clone();
xDate.set(Calendar.DATE, -1);
System.out.println(xDate.getTime().toString());
But the result is: Thu Nov 29 17:18:50 GMT+05:30 2012
when I am was hoping it would be 16th December. Any help will be appreciated.
Thank you.