iOS5からtwitterの認証がデフォルトで装備されましたが、一体どうやって使うの?
色々調べた結果、めちゃくちゃ簡単に使えることが判明。
#import <Accounts/Accounts.h>
ACAccountStore *aCAccountStore = [[ACAccountStore alloc] init];
ACAccountType *aCAccountType = [aCAccountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[aCAccountStore requestAccessToAccountsWithType:aCAccountType withCompletionHandler:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"grandted");
}else{
NSLog(@"not grandted");
}
}];
AccountsFrameworkをインポートして上のようにコードすればおkgratedがYESの場合、twitterの情報を取得することができるようになります。

上のようなアラートがでて、「OK」を押せば取得することができるようになります。
むちゃくちゃ便利。
0 コメント:
コメントを投稿