I am trying to fetch the friends of the user (who is logged in into his FaceBook account) based upon the gender of his friends and based upon the pic_big!=NULL
(Every friend should have a big profile picture).
Below is my code that I am writing.
NSString *queryString = [NSString stringWithFormat:@"%@%@%@%@%@%@%i%@%@",
@"SELECT name, pic_big, sex, uid FROM user ",
@"WHERE sex=", @"male", @" AND ",
@"pic_big != 'null' AND uid IN (SELECT uid2 ",
@"FROM friend WHERE uid ", loggedInID, @" )",
@"ORDER BY name"];
NSMutableDictionary *dictionary=[NSMutableDictionary
dictionaryWithObjectsAndKeys:queryString,@"query", nil];
[FBRequest getRequestWithParams:dictionary
httpMethod:@"GET"
delegate:self
requestURL:@"fql.query"];
loggedINiD
is the user's login ID. I am not getting any response开发者_StackOverflow社区 in the delegate methods. I am sure I need to recheck this SQL query. Any suggestions please.
You have a couple of errors in your FQL code and adding one suggestion I would make for simplicity, here is what you should query instead:
SELECT name, pic_big, sex, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = "male"
Things to note:
- uid1 is the correct index field for the friend table, not uid
- You were missing the equals sign after "FROM friend WHERE uid"
- me() is a helper function in FQL which represents the current session user (ie. the app user)
- pic_big will never be null, as even the default Profile pic for users on Facebook returns a value for this, so testing for it is redundant.
- I've changed the order of the WHERE clause, but that shouldn't matter.
NSString *queryString = [NSString stringWithFormat:@"SELECT name, pic_big, sex, uid FROM user WHERE sex='male' AND pic_big != 'null' AND uid IN (SELECT uid2 FROM friend WHERE uid = %i) ORDER BY name", loggedInID];
Use this queryString. I am not sure but think this will help you.
精彩评论