iOS Social和Accounts简单使用
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *type = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierSinaWeibo];
[account requestAccessToAccountsWithType:type options:nil completion:^(BOOL granted, NSError *error) {
if (granted)
{
NSArray *array = [account accountsWithAccountType:type];
NSLog(@"账号%@",array);
if (array.count > 0)
{
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeSinaWeibo requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://api.weibo.com/2/common/get_city.json"] parameters:[NSDictionary dictionaryWithObject:@"001011" forKey:@"province"]];
request.account = [array objectAtIndex:0];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
//NSLog(@" == %@",responseData);
NSError *errorr = nil;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&errorr];
if (!error)
{
NSLog(@"北京区 %@",dic);
}
}];
}
}
}];