简体   繁体   中英

Facebook Friend List Graph API

如何从用户那里获得朋友列表,以及有关他们的更多信息(例如亲戚,生日等)?

You can run a FQL query like:

SELECT uid, name, birthday, relationship_status, pic_square 
FROM user 
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

You can add more user fields as needed. You will need varying extended permissions based on what you are trying to get.

as per Facebook developer guideline you can access in following ways :

> // Query to fetch the active user's friends, limit to 25.
>     NSString *query =
>     @"SELECT uid, name, pic_square FROM user WHERE uid IN "
>     @"(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)";
>     // Set up the query parameter
>     NSDictionary *queryParam =
>     [NSDictionary dictionaryWithObjectsAndKeys:query, @"q", nil];
>     // Make the API request that uses FQL
>     [FBRequestConnection startWithGraphPath:@"/fql"
>                                  parameters:queryParam
>                                  HTTPMethod:@"GET"
>                           completionHandler:^(FBRequestConnection *connection,
>                                               id result,
>                                               NSError *error) {
>                               if (error) {
>                                   NSLog(@"Error: %@", [error localizedDescription]);
>                               } else {
>                                   NSLog(@"Result: %@", result);
>                               }
>                           }];

First of all you need the user to accept your permission to get this data:

https://developers.facebook.com/docs/reference/api/permissions/

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