简体   繁体   中英

how can i get friends list from Facebook who using my application

I have a requirement like need to fetch the friends who are using my application. Same as Instagram application Find friends from Facebook.

I know this is code which provides the friends list.

- (void) getFriendName :(id) sender {

        self.modeString = @"friendName";

        NSString * query = [NSString stringWithFormat:@"SELECT name FROM user WHERE uid IN (SELECT uid1 FROM friend WHERE uid2=me())",appDelegate.friendList];
        NSLog(@"query :%@",query);
    //    NSString * query = [NSString stringWithFormat:@"SELECT uid, first_name, last_name, birthday_date, sex, pic_square, current_location, hometown_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND strlen(birthday_date) != 0 ORDER BY birthday_date",appDelegate.friendList];
        NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                        query, @"query",
                                        nil];
        [_facebook requestWithMethodName:@"fql.query"
                               andParams:params
                           andHttpMethod:@"POST"
                             andDelegate:self];
    } 

Among these friends list, how can I retrieve only friends using my application?

如果要在服务器上维护数据,请在服务器端进行Facebook集成。

Here is the query that I have been using

    NSString *isAppUser = usesApp ? @"1" : @"0";
NSString *query = [NSString stringWithFormat:@"SELECT uid FROM user WHERE is_app_user = %@ AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) LIMIT %d",
                   isAppUser, limit];
FBRequest *request = [FBRequest requestWithGraphPath:@"/fql" parameters:@{@"q":query} HTTPMethod:@"GET"];

You can just remove the limit and just have isAppUser always be @"1"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM