简体   繁体   中英

IOS: Get Facebook friends who play app

I have managed to get the friendslist:

//token
NSString *acessToken = [NSString stringWithFormat:@"%@",_facebookAccount.credential.oauthToken];
NSDictionary *parameters = @{@"access_token": acessToken};
// Create the URL to the end point
NSURL *friendsList = [NSURL URLWithString:@"https://graph.facebook.com/me/friends"];

// Create the SLReqeust
SLRequest *getFriends = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:friendsList parameters:parameters];

I also need need to get which friends that are playing, but get an error:

 me/friends?fields=installed


{
    error =     {
        code = 2500;
        message = "An active access token must be used to query information about the current user.";
        type = OAuthException;
    };
}

Is there a special permission I need to request for this? I use these now:

@"read_stream", @"email", @"read_friendlists"

thanks

you can get Fb Friend list who use App like bellow method:-

- (void)apiRESTGetAppUsers {

    //[self apiGraphFriends];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"friends.getAppUsers", @"method",
                                   nil];
    [[objapp facebook] requestWithParams:params
                             andDelegate:self];
}

- (void)request:(FBRequest *)request didLoad:(id)result {


    NSMutableArray *friendsWithApp = [[NSMutableArray alloc] initWithCapacity:1];
    // Many results
    if ([result isKindOfClass:[NSArray class]]) {
        [friendsWithApp addObjectsFromArray:result];
    } else if ([result isKindOfClass:[NSDecimalNumber class]]) {
        [friendsWithApp addObject: [result stringValue]];
    }




    NSLog(@"Array of all userfrnd of faceboolk   == %@",friendsWithApp);
}

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