프레임워크는 Social.framework 와 Accounts.framework가 필요하다.
m_accountStore = [[ACAccountStore alloc] init];
[m_accountStore requestAccessToAccountsWithType:twitterAccountType options:nil
completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [m_accountStore accountsWithAccountType:twitterAccountType];
ACAccount *twitterAccount = [accounts lastObject];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:twitterAccount.username, @"screen_name", [[twitterAccount valueForKey:@"properties"] valueForKey:@"user_id"], @"user_id", nil];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:@"https://api.twitter.com/1/users/show.json"]
parameters:params];
[request setAccount:[accounts lastObject]];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if (error == nil && urlResponse.statusCode >= 200 && urlResponse.statusCode < 300) {
NSDictionary *userDic = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
//usreDic에 정보가 담겨져있다.~!
}//end if
}];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
handlerBlock(nil);
});
}//end if
}];
'Development > IOS & Mac' 카테고리의 다른 글
[iOS] iOS 7 status bar에서 hidden이 되지 않을때~!! (0) | 2014.03.05 |
---|---|
[iOS] NSLocalizedString 사용해보기~! (0) | 2014.02.27 |
[iOS] facebook iOS 단말기에 있는 유저 정보 가져오기 (0) | 2014.02.26 |
[iOS] performselector may cause a leak because its selector is unknown (0) | 2014.02.24 |
[iOS] 기본 UI 색깔 변경하기 (0) | 2014.02.24 |