As a part of my project I need to show the list of tweets in iOS app. I tried with the below code but its returning the JSON. The same code is works fine with version 1. Now the twitter api version is 1.1 and one another warning I got that TWRequest is deprecated
. This deprecation is not the issue of this even I got same thing with SLRequest
. Here my problem is I need to fetch the JSON of Particular user tweets without authentication or with authentication
TWRequest *postequest=[[TWRequest alloc]initWithURL:[NSURL URLWithString:@"https://api.twitter.com/1.0/statuses/user_timeline.json?screen_name=coolCracker&count=2"] parameters:nil requestMethod:TWRequestMethodGET];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output;
if ([urlResponse statusCode]==200) {
NSError *err;
NSDictionary *PublicTimeline=[NSJSONSerialization JSONObjectWithData:responseData options:0 error:&err];
output=[NSString stringWithFormat:@"HTTP response status: %li\nPublic timeline:\n%@",(long)[urlResponse statusCode],PublicTimeline];
}
else
{
output=[NSString stringWithFormat:@"No feed HTTP response was: %li\n",(long)[urlResponse statusCode]];
}
[self performSelectorOnMainThread:@selector(displayResults:) withObject:output waitUntilDone:NO];
}];
-(void)displayResults:(NSString *)text
{
NSLog(@"tweets feed %@",text);
}