Reputation: 3356
I have a simple question, in my iOS app I have the twitter search api. I am looking to implement instead a search for hastags and user timelines. For hastags I have the url: http://search.twitter.com/search.json?q=%23HASHTAGHERE But I was unable to find the JSON url for a user's timeline. If someone can point me to this that would be great. Thank You
CURRENT FOR 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:request delegate:self];
Upvotes: 0
Views: 2832
Reputation: 3211
The URL for a user's timeline: https://api.twitter.com/1.1/statuses/user_timeline.json
Source: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
Note that this is for iOS 5+ since it uses 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
}
}];
If you just want a JSON timeline without any authentication, etc, then you can use: http://api.twitter.com/1/statuses/user_timeline.json?screen_name=(screen-name-here)
Upvotes: 1