2017-11-24 13 views
0
트위터 키트 (이미지 URL, 사용자 이름, 이메일 등)

내가 이메일 ID, 사용자 이름 및 로그인 후 내 트위터 계정에서 이미지 URL,어떻게 기록 얻을 수있는 사용자 세부 아이폰 OS

전류를 얻을 수있는 방법 코드는 다음과 같습니다 profImageemailId을 얻기 위해

[[Twitter sharedInstance] logInWithCompletion:^ (TWTRSession *session, NSError *error) 
{ 

    if (session) 
    { 
     NSLog(@"signed in as %@", [session userName]); 
    } 
    else 
    { 
     NSLog(@"error: %@", [error localizedDescription]); 
    } 

}]; 

답변

0

도움 다음 코드 될 수 있습니다.

TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) { 
    // play with Twitter session 
    if (session) { 
     NSLog(@"Twitter signed in as -> name = %@ id = %@ ", [session userName],[session userID]); 

     /* Get user info */ 
     [[[Twitter sharedInstance] APIClient] loadUserWithID:[session userID] 
                completion:^(TWTRUser *user, 
                   NSError *error) 
     { 
      // handle the response or error 
      if (![error isEqual:nil]) { 
       NSLog(@"Twitter info -> user = %@ ",user); 
       NSString *urlString = [[NSString alloc]initWithString:user.profileImageLargeURL]; 
       NSURL *url = [[NSURL alloc]initWithString:urlString]; 
       NSData *pullTwitterPP = [[NSData alloc]initWithContentsOfURL:url]; 

       UIImage *profImage = [UIImage imageWithData:pullTwitterPP]; 


      } else { 
       NSLog(@"Twitter error getting profile : %@", [error localizedDescription]); 
      } 
     }]; 

    } else { 
     NSLog(@"Twitter error signed in : %@", [error localizedDescription]); 
    } 
}]; 

// Get user email address 
-(void)requestUserEmail 
{ 
    if ([[Twitter sharedInstance] session]) { 

     TWTRShareEmailViewController *shareEmailViewController = 
     [[TWTRShareEmailViewController alloc] 
     initWithCompletion:^(NSString *email, NSError *error) { 
      NSLog(@"Email %@ | Error: %@", email, error); 
     }]; 

     [self presentViewController:shareEmailViewController 
          animated:YES 
         completion:nil]; 
    } else { 
     // Handle user not signed in (e.g. attempt to log in or show an alert) 
    } 
}