TwitterKit框架没有获得电子邮件密钥

时间:2017-02-15 13:02:33

标签: ios objective-c twitter-fabric twitterkit

我使用Fabric和版本2.8.0的TwitterKit框架。我按照https://docs.fabric.io/apple/twitter/log-in-with-twitter.html#request-user-email-address按照说明进行操作 并且已经检查了从用户请求电子邮件地址访问的许可。但我没有得到" verify_credentials"有时候会做出回应,有时候我没有得到#34;电子邮件"密钥在verify_credentials API响应中。

1 个答案:

答案 0 :(得分: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]);
    }
  }];    
  }