昨日、SocialFrameworkを使ってSinaWeiboの認証を行う方法を書きましたが、プロフィール情報を取得するにはどうすればいいのだろうか?
#import <Accounts/Accounts.h> #import <Social/Social.h> ACAccountStore *aCAccountStore = [[ACAccountStore alloc] init]; ACAccountType *aCAccountType = [aCAccountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierSinaWeibo]; [aCAccountStore requestAccessToAccountsWithType:aCAccountType withCompletionHandler:^(BOOL granted, NSError *error) { if (granted) { NSArray *acAccounts = [aCAccountStore accountsWithAccountType:aCAccountType]; ACAccount *acAccount = [acAccounts objectAtIndex:0]; SLRequest *sLRequest = [SLRequest requestForServiceType:SLServiceTypeSinaWeibo requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://api.weibo.com/2/users/show.json"] parameters:@{@"screen_name":acAccount.username}]; sLRequest.account = acAccount; [sLRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){ if(!error){ NSDictionary *dictJSON = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil]; NSLog(@"%@",dictJSON); } }]; }else{ } }];キーポイントは、Twitterと同じで「https://api.weibo.com/2/users/show.json」でプロフィール情報を返してくれることですね。
0 コメント:
コメントを投稿