首页 > 移动平台 > 详细

iOS Social和Accounts简单使用

时间:2017-07-15 12:24:40      阅读:450      评论:0      收藏:0      [点我收藏+]

    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);

                    }

                }];

            }

        }

    }];

iOS Social和Accounts简单使用

原文:http://www.cnblogs.com/zhenghaimin/p/7182026.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!