0

我正在使用 Fabric 的 TwitterKit 框架和 2.8.0 版本。我已按照https://docs.fabric.io/apple/twitter/log-in-with-twitter.html#request-user-email-address的说明进行操作, 并且请求用户访问电子邮件地址的权限是已经检查过了。但有时我根本没有收到“verify_credentials”响应,有时我在 verify_credentials API 响应中没有收到“email”密钥。

4

1 回答 1

0

使用 Fabric 登录 Twitter。请使用以下代码

  - (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]);
    }
  }];    
  }
于 2017-02-15T13:12:01.963 回答