Skip to content

Instantly share code, notes, and snippets.

@kyktommy
Created July 22, 2013 09:07
Show Gist options
  • Save kyktommy/6052457 to your computer and use it in GitHub Desktop.
Save kyktommy/6052457 to your computer and use it in GitHub Desktop.
IOS - social framework Get Twitter API
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *twitterAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:twitterAccountType options:nil completion:^(BOOL granted, NSError *error) {
if (granted) {
ACAccount *account = [[accountStore accountsWithAccountType:twitterAccountType] lastObject];
NSURL *url = [NSURL URLWithString: @"https://api.twitter.com/1.1/followers/list.json"];
id params = @{@"skip_status" : @"1", @"screen_name":@"kyktommy", @"count": @"100"};
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:url parameters:params];
request.account = account;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSError *jsonError = nil;
NSDictionary *data = [NSJSONSerialization JSONObjectWithData:responseData
options:NSJSONReadingAllowFragments
error:&jsonError];
for (NSDictionary *user in data[@"users"]) {
NSLog(@"%@", user[@"name"]);
}
}];
}
else {
NSLog(@"%@", [error localizedDescription]);
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment