Reputation: 87
I am trying to write a query in xCode to get my friend's events from FB. The problem is that now it returns me past events as well:
@"SELECT name, pic_square, pic, start_time, location, description, pic_cover, venue, eid from event WHERE eid in "
@"(SELECT eid from event_member WHERE uid IN(SELECT uid2 FROM friend WHERE uid1=me()))"
After a lot of research I managed to came up with a logical solution, but it doesn't work:
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSString *currDateString = [dateFormatter stringFromDate:currDate];
NSString *query = [NSString stringWithFormat:
@"SELECT name, pic_square, pic, start_time, location, description, pic_cover, venue, eid from event WHERE eid in "
@"(SELECT eid from event_member WHERE uid IN(SELECT uid2 FROM friend WHERE uid1=me())) WHERE start_time > %@" ,currDateString];
Can somebody please help me figure this out? I am new with FQLs. Thanks!
Upvotes: 0
Views: 590
Reputation: 119031
Don't bother specifying the date yourself, get the server to do it by using start_time > now()
.
Upvotes: 2
Reputation: 3815
Facebooks asks for time in epoch format. If you want to fetch any data on the basis of date. You need to send the date in epoch format (UNIX Time Format).
This is how you can get the time which FQL is asking for :
[[NSDate date] timeIntervalSince1970];
So the query would be :
NSString *query = [NSString stringWithFormat:
@"SELECT name, pic_square, pic, start_time, location, description, pic_cover, venue, eid from event WHERE eid in "
@"(SELECT eid from event_member WHERE uid IN(SELECT uid2 FROM friend WHERE uid1=me())) WHERE start_time > %ld" ,[[NSDate date] timeIntervalSince1970]];
Upvotes: 0