2013-03-11 25 views
1

我設法得到friendslist:IOS:獲取Facebook上的朋友誰發揮應用

//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]; 

我還需要需要得到其朋友被打,卻得到一個錯誤:

me/friends?fields=installed 


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

我有需要特別許可嗎?我現在這些使用方法:

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

感謝

回答

1

你可以得到誰使用App像波紋管法Fb的朋友列表: -

- (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); 
} 
+0

感謝您的答覆。這段代碼是否使用SLRequest?我沒有得到「[[objapp facebook]」,我是否需要爲此實現Facebook舊SDK? – BlackMouse 2013-03-11 07:36:39

+0

我使用舊的FBconnect和使用我發佈的代碼其工作好..! – 2013-03-11 07:37:34

+0

該解決方案似乎使用FB SDK。 iOS Social Framework中是否有等效的方法?例如使用SLRequest? – zeeple 2013-05-09 16:06:36