2017-02-15 19 views
0

Я использую структуру TwitterKit от Fabric и версии 2.8.0. Я выполнил инструкции согласно https://docs.fabric.io/apple/twitter/log-in-with-twitter.html#request-user-email-address И разрешение на запрос адреса электронной почты от пользователя уже проверено. Но иногда я не получаю ответ «verify_credentials», иногда я не получаю ключ «email» в ответе API verify_credentials.Структура TwitterKit не получает ключ электронной почты

ответ

0

Twitter Войти используя 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

Спасибо, я только что забыл упомянуть о сетевом подходе. –