0

我有一个简单的问题,在我的 iOS 应用程序中,我有 twitter 搜索 api。我正在寻求实现对 hastags 和用户时间线的搜索。对于 hastags,我有网址:http ://search.twitter.com/search.json?q=%23HASHTAGHERE但我无法找到用户时间线的 JSON 网址。如果有人能指出这一点,那就太好了。谢谢你

HATAG 的电流:

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:request delegate:self];

4

1 回答 1

1

用户时间线的 URL: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)

于 2013-03-25T05:38:13.390 回答