Created
July 22, 2013 09:07
-
-
Save kyktommy/6052457 to your computer and use it in GitHub Desktop.
IOS - social framework
Get Twitter API
This file contains hidden or 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
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