xcode 如何使用 Objective-c 从 Twitter 获取用户帐户信息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9464327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:27:23  来源:igfitidea点击:

How to get user account information from Twitter using objective-c?

iphonexcodetwittertwitter-oauth

提问by Jamal Zafar

i have used oauth mechanism to let the user login via twitter in my app, on successful login it returns me the access taken, username and oauth_token_secret, i want to get the user account information from twitter like his location, date of birth, and other profile information. I have searched the Rest Api given on the twitter's official site but haven't found any such link.... so how to get the user 's account information? kindly help me.

我已经使用 oauth 机制让用户在我的应用程序中通过 twitter 登录,成功登录后,它会返回访问权限、用户名和 oauth_token_secret,我想从 twitter 获取用户帐户信息,例如他的位置、出生日期和其他档案信息。我搜索了推特官网给出的Rest Api,但是没有找到这样的链接....那么如何获取用户的账号信息呢?请帮助我。

采纳答案by Mohit Jain

what about thiscall

这个电话怎么样

 https://api.twitter.com/1/users/show.json?screen_name=TwitterAPI&include_entities=true

回答by Sawan Cool

Twitter-Kit Version 3.4.0 Here is function

Twitter-Kit 版本 3.4.0 这是函数

-(void)userVerify:(NSString *)userID{
    NSString *statusesShowEndpoint = @"https://api.twitter.com/1.1/users/show.json";
    NSDictionary *params = @{@"id": userID};
    NSError *clientError;
    // Objective-C
    TWTRAPIClient *client = [[TWTRAPIClient alloc] init];
    NSURLRequest *request = [client URLRequestWithMethod:@"GET" URLString:statusesShowEndpoint parameters:params error:&clientError];
    if (request) {
        [client
         sendTwitterRequest:request
         completion:^(NSURLResponse *response,
                      NSData *data,
                      NSError *connectionError) {
             if (data) {
                 // handle the response data e.g.
                 NSError *jsonError;
                 NSDictionary *json = [NSJSONSerialization
                                       JSONObjectWithData:data
                                       options:0
                                       error:&jsonError];
                 NSLog(@"%@",[json description]);
                 self.txtViewDetails.text = [json description];
             }
             else {
                 NSLog(@"Error code: %ld | Error description: %@", (long)[connectionError code], [connectionError localizedDescription]);
                 self.txtViewDetails.text = [NSString stringWithFormat:@"Error code: %ld | Error description: %@", (long)[connectionError code], [connectionError localizedDescription]];
             }
         }];
    }
    else {
        NSLog(@"Error: %@", clientError);
    }
}