2017-02-15 6 views
0

저는 TwitterKit 프레임 워크를 Fabric 및 버전 2.8.0에서 사용하고 있습니다. 나는 지침을 따랐다. https://docs.fabric.io/apple/twitter/log-in-with-twitter.html#request-user-email-address 그리고 사용자로부터 전자 메일 주소 액세스를 요청할 수있는 권한이 이미 확인되었습니다. 그러나 나는 때때로 "verify_credentials"응답을 얻지 못하고 때로는 verify_credentials API 응답에 "email"키를 얻지 못합니다.TwitterKit 프레임 워크가 이메일 키를받지 못합니다

답변

0

Fabric을 사용하여 로그인하십시오. 아래 코드를 사용하십시오.

- (IBAction)TwitteClickAction:(id)sender 
    { 

    [[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBased completion:^(TWTRSession *session, NSError *error) 
    { 
    if (session) 
    { 
     NSLog(@"signed in as %@", [session userName]); 
     NSLog(@"signed id in as %@", [session userID]); 
     TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser]; 
     NSURLRequest *request = [client URLRequestWithMethod:@"GET" 
                 URL:@"https://api.twitter.com/1.1/account/verify_credentials.json" 
                parameters:@{@"include_email": @"true", @"skip_status": @"true"} 
                 error:nil]; 

     [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) 
     { 
      if (data) 
      { 
       NSError *jsonError; 
       NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; 
       NSLog(@"info is ====>%@",json); 

      } 
      else { 
       NSLog(@"Error: %@", connectionError); 
      } 
     }]; 

    } else { 
     NSLog(@"error: %@", [error localizedDescription]); 
    } 
    }];  
    } 
+0

감사합니다. 웹 기반 접근 방식에 대해 언급하는 것을 잊어 버렸습니다. –