views:

2250

answers:

2

I'm trying to get a list of user's friends using fb connect for the iphone.

I've tried both of the following FQL Queries, but they don't seem to be returning anything.

which one is correct if any ?

NSString* fql = [NSString stringWithFormat:@"select flid,name from friendlist where owner=%lld",[self fbSession].uid];

or

NSString* fql = [NSString stringWithFormat:@"SELECT flid,uid FROM friendlist_member WHERE flid IN (SELECT flid FROM friendlist WHERE owner=%lld)",[self fbSession].uid];
A: 

Ah.. figured it out...

NSString* fql = [NSString stringWithFormat:@"SELECT name,uid FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1=%lld )",[self fbSession].uid];
dizy
A: 

Can anyone tell me how to handle the response ?

Prasad-PHP Champ
You implement a delegate - (void)request:(FBRequest*)request didLoad:(id)result { if ([request.method isEqualToString:@"facebook.fql.query"]) { NSArray* users = result; if([users count]>0){ NSDictionary* user = [users objectAtIndex:0]; NSString* name = [user objectForKey:@"name"]; NSNumber* uid = [user objectForKey:@"uid"]; if([self fbSession].uid == [uid longLongValue]){ //got user's name } else { //got user's friends } } else { //no friends probably }
dizy