public
Last active

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/user_timeline.json"];
Class socialRequestClass = NSClassFromString(@"SLRequest");
id request = nil;
if ( socialRequestClass != nil ) {
request = [socialRequestClass requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodGET
URL:url
parameters:nil];
} else {
request = [[TWRequest alloc] initWithURL:url
parameters:nil
requestMethod:TWRequestMethodGET];
}
 
[request setAccount:[self twitterAccount]];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if ( responseData == nil ) {
NSLog(@"%@", error);
} else {
NSError *JSONError = nil;
NSDictionary *response = [NSJSONSerialization JSONObjectWithData:responseData
options:NSJSONReadingMutableLeaves
error:&JSONError];
if ( response == nil ) {
NSLog(@"%@", JSONError);
} else {
NSLog(@"response: %@", response);
}
}
}];

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.