Created
October 10, 2012 16:43
-
-
Save volonbolon/3866791 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment