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

时间:2012-02-27 11:34:10

标签: iphone xcode twitter twitter-oauth

我使用oauth机制让用户在我的应用程序中通过twitter登录,成功登录后返回我的访问权限,用户名和oauth_token_secret,我想从Twitter获取用户帐户信息,如他的位置,出生日期和其他个人资料信息。我在twitter的官方网站上搜索了Rest Api,但是没有找到任何这样的链接....那么如何获取用户的帐户信息呢​​?请帮助我。

2 个答案:

答案 0 :(得分:3)

this来电

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

答案 1 :(得分:0)

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);
    }
}