views:

301

answers:

2

I want to retrieve the status data posted/published by friends of a user. I wrote the following code, but only get the user's own status updates. Could someone please help to tell me what's wrong with my code? Thanks!

NSString *fql = [NSString stringWithFormat:@"select uid,message from status where uid in (select uid2 from friend where uid1=%lld) order by time desc ", uid];

NSDictionary *params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.Status.get" params:params];  
+1  A: 

You need to change the call to use "facebook.fql.query" since you're doing a direct query.

Here's my code for getting the last 20 friends updates:

NSString* fql = [NSString stringWithFormat:
                 @"SELECT uid, pic_square, name, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld) AND status.time > 0 ORDER BY status.time DESC LIMIT 20", fbSession.uid];

NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
last20FriendsStatusRequest = [FBRequest requestWithDelegate:self];
[last20FriendsStatusRequest call:@"facebook.fql.query" params:params];

Best regards,

Matt Long
Hi Matt,Thanks for the hint. :-)BTW, could you explain more about "direct query"? I'm always confused when I shall use fql.query or User.setStatus etc.Thanks.
Naive one
Both "facebook.fql.query" and "facebook.status.get" are web service calls. One takes an FQL query as a parameter while the other doesn't. FQL queries allow you to use more specific query language to get the exact results you're after while the status call is doing a specific query behind the scenes.
Matt Long
Great answer! Thanks!
Naive one
A: 

Hmmm - why does me doing exactly what you guys did get me an empty result? been at this for hours, but haven't gotten anywhere. Please help..

PinkFloydRocks