用户时间线的Twitter JSON URL

时间:2013-03-24 17:29:48

标签: ios twitter hashtag

我有一个简单的问题,在我的iOS应用程序中,我有twitter搜索API。我希望实现搜索hastags和用户时间线。对于hastags我有网址:http://search.twitter.com/search.json?q=%23HASHTAGHERE但是我无法找到用户时间轴的JSON网址。如果有人可以指出我这将是伟大的。谢谢

目前HASTAG:

NSString *urlString = [NSString stringWithFormat:@"http://search.twitter.com/search.json?q=&ands=%@&phrase=&rpp=50",searchTerm];
  NSURL *url = [NSURL URLWithString:urlString];       //Setup and start async download    
     

NSURLRequest * request = [[NSURLRequest alloc]   initWithURL:URL]; NSURLConnection * connection = [[NSURLConnection   alloc] initWithRequest:请求委托:self];

1 个答案:

答案 0 :(得分:1)

用户时间轴的网址:https://api.twitter.com/1.1/statuses/user_timeline.json

来源:https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline

请注意,这适用于iOS 5+,因为它使用TWRequest

    NSURL *getTimeline = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/user_timeline.json"];

    NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
                               <twitter screen name goes here>, @"screen_name",
                                nil];

    TWRequest *twitterRequest = [[TWRequest alloc] initWithURL:getTimeline
                                                    parameters:parameters
                                                 requestMethod:TWRequestMethodGET];

//Set a twitter account (Gotten from iOS 5+)
    [twitterRequest setAccount:self.twitterAccount];

    [twitterRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
     {
         if (!error)
         {             
             JSONDecoder *decoder = [[JSONDecoder alloc] initWithParseOptions:JKParseOptionNone];
             NSArray *twitterTimeline = [decoder objectWithData:responseData];

         }
         else
         {
             //Deal with error
         }


     }];

如果您只想要一个没有任何身份验证的JSON时间线等,那么您可以使用: http://api.twitter.com/1/statuses/user_timeline.json?screen_name=(screen-name-here)