Facebook iOS SDK and swift: how get user's profile picture

前端 未结 10 1545
天涯浪人
天涯浪人 2021-01-31 03:51

i have integrated Facebook sdk in Xcode 6 (with swift). During the login i request the public_profile permission:

FBSession.openActiveSessionWithReadPermissions(         


        
10条回答
  •  你的背包
    2021-01-31 04:50

    if you want get bigger picture , just replace "type = large" to width=XX&height=XX

    but the biggest picture you can get is original picture

    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] 
                                  initWithGraphPath:@"me/picture?width=1080&height=1080&redirect=false" 
                                  parameters:nil 
                                  HTTPMethod:@"GET"]; 
    
    [request startWithCompletionHandler:^(
                                FBSDKGraphRequestConnection *connection,
                                id result, 
                                NSError *error) { 
    if (!error) 
    { 
       NSLog(@"result = %@",result);
       NSDictionary *dictionary = (NSDictionary *)result; 
       NSDictionary *data = [dictionary objectForKey:@"data"]; 
       NSString *photoUrl = (NSString *)[data objectForKey:@"url"]; 
    } 
    else 
    { 
       NSLog(@"result = %@",[error description]); } 
    }];
    

提交回复
热议问题