【问题标题】:Twitter API Email not getting IOSTwitter API 电子邮件未获取 IOS
【发布时间】:2017-08-12 07:07:11
【问题描述】:

我使用这些代码来接收用户的电子邮件,但是电子邮件不是从 twitter API 获得的。我的帐户已验证,我设置了准确的 twitter 应用程序设置。我的帐户已验证,我设置了准确的 twitter 应用程序设置。

- (IBAction)twitterLogin:(id)sender {
[[Twitter sharedInstance] logInWithCompletion:^
 (TWTRSession *session, NSError *error) {
     if (session) {
         NSLog(@"signed in as %@", [session userName]);
         NSLog(@"%@", [session userID]);
         NSLog(@"%@", [session userName]);
         NSLog(@"%@", [session authToken]);
         NSLog(@"%@", [session authTokenSecret]);

         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) {

             NSDictionary *result = [NSJSONSerialization
                                   JSONObjectWithData:data
                                   options:0
                                   error:nil];


             NSString * deviceToken = UD_getObj(@"deviceToken");
             NSLog(@"%@",result);
             [[AFHTTPRequestOperationManager manager]GET:DEF_URL(@"user/twitterLogin") parameters:@{@"name":result[@"first_name"],@"surname":@" ",@"gender":@" ",@"twID":result[@"id_str"],@"imageLink":result[@"profile_image_url"],@"email":result[@"email"],@"deviceToken":(deviceToken.length > 0 ? UD_getObj(@"deviceToken") : @" ")} success:^(AFHTTPRequestOperation *operation, id responseObject) {
                 NSLog(@"%@",responseObject);
                 UD_setObj(@"loginData", responseObject);
                 UD_sync();
                 [[AppDelegate sharedAppDelegate]hideLoadingView];
                 [[AppDelegate sharedAppDelegate]loginSuccess];

             } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                 NSLog(@"%@",operation.responseString);
                 [[AppDelegate sharedAppDelegate]showMessage:@"Error" :@"An Error Occured Code : 80" :2 :self ];
                 [[AppDelegate sharedAppDelegate]hideLoadingView];
             }];



         }];

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

}

结果是

2017-03-20 23:08:40.030206 Freger[652:180499] [core] Prepared Request URL: https://api.twitter.com/oauth/access_token
2017-03-20 23:08:40.981167 Freger[652:180499] signed in as Berkzsoy1
2017-03-20 23:08:40.981494 Freger[652:180499] 463092374
2017-03-20 23:08:40.981692 Freger[652:180499] Berkzsoy1
2017-03-20 23:08:40.981889 Freger[652:180499] 463092374-ZqlfFhJLAyowxdtNHyRFLopChO1h0zfp4NpkY171
2017-03-20 23:08:40.982080 Freger[652:180499] ydvwd3E3gvg7FKWxe4ILpKxY3NjSoQhtrxKtRSF6cbVeV
2017-03-20 23:08:41.304113 Freger[652:180499] {
    "contributors_enabled" = 0;
    "created_at" = "Fri Jan 13 18:22:19 +0000 2012";
    "default_profile" = 0;
    "default_profile_image" = 0;
    description = "";
    entities =     {
        description =         {
            urls =             (
            );
        };
    };
    "favourites_count" = 24;
    "follow_request_sent" = 0;
    "followers_count" = 41;
    following = 0;
    "friends_count" = 104;
    "geo_enabled" = 0;
    "has_extended_profile" = 0;
    id = 463092374;
    "id_str" = 463092374;
    "is_translation_enabled" = 0;
    "is_translator" = 0;
    lang = tr;
    "listed_count" = 0;
    location = "";
    name = "Berk \U00d6zsoy";
    notifications = 0;
    "profile_background_color" = ABB8C2;
    "profile_background_image_url" = "http://abs.twimg.com/images/themes/theme12/bg.gif";
    "profile_background_image_url_https" = "https://abs.twimg.com/images/themes/theme12/bg.gif";
    "profile_background_tile" = 0;
    "profile_banner_url" = "https://pbs.twimg.com/profile_banners/463092374/1419816548";
    "profile_image_url" = "http://pbs.twimg.com/profile_images/620996292135665664/XPuYYAEO_normal.jpg";
    "profile_image_url_https" = "https://pbs.twimg.com/profile_images/620996292135665664/XPuYYAEO_normal.jpg";
    "profile_link_color" = DD2E44;
    "profile_sidebar_border_color" = EEEEEE;
    "profile_sidebar_fill_color" = F6F6F6;
    "profile_text_color" = 333333;
    "profile_use_background_image" = 1;
    protected = 0;
    "screen_name" = Berkzsoy1;
    "statuses_count" = 14;
    "time_zone" = "<null>";
    "translator_type" = none;
    url = "<null>";
    "utc_offset" = "<null>";
    verified = 0;
}

【问题讨论】:

    标签: ios objective-c twitter


    【解决方案1】:

    根据documentation for this endpoint

    “向用户请求电子邮件地址”复选框位于 apps.twitter.com 上的应用权限。隐私政策 URL 和条款 的服务 URL 字段必须在应用设置中按顺序填写 用于访问功能的电子邮件地址。如果启用,用户将 通过 oauth/authorize 对话框通知您的应用可以访问他们的 电子邮件地址。

    您是否激活了此复选框并填写了其他必填字段以访问电子邮件地址?

    【讨论】:

    • 我激活了,但是我的应用程序中没有弹出 oauth/authorize 对话框。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 2013-11-06
    • 2014-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多