Facebook第三方登陆
2015-09-22 17:10
399 查看
Facebook的第三方登陆非常简单,但是在登陆后获取用户资料时却让人非常头疼,不像国内,会直接返回一个包含着各种需要用到的用户数据的字典,而是需要通过Graph API自己获取,而且获取的时候需要设置各种Key值,而最最最让人头疼的是,有些key值在官方文档里没有标出,只能自己试。。。。。目前笔者还没有找到哪里有非常详细的介绍(可能是我英语不好吧。。。)
下面直接贴代码
下面直接贴代码
sender.selected = !sender.selected; FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; [login logInWithReadPermissions:@[@"public_profile",@"user_about_me"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if (error) { NSLog(@"Process error"); } else if (result.isCancelled){ NSLog(@"Cancelled"); } else if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"user_about_me"]){ NSDictionary *para = @{@"fields":@"id,name,email,age_range,link,gender,locale,timezone,updated_time,verified,picture"}; FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:para HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { if (!error) { NSLog(@"request : result %@",(NSDictionary *)result); dispatch_async(dispatch_get_main_queue(), ^{ NSString *str = [[[result valueForKey:@"picture"] valueForKey:@"data"] valueForKey:@"url"]; NSLog(@"%@",str); NSURL *url = [NSURL URLWithString:str]; NSData *data = [NSData dataWithContentsOfURL:url]; UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageWithData:data]]; imageView.bounds = CGRectMake(0, 0, 100, 100); imageView.center = self.view.center; [self.view addSubview:imageView]; }); } else { NSLog(@"error : %@",error.userInfo); } }]; } }];
相关文章推荐
- Caused by: java.lang.IllegalArgumentException: addChild: Child name 'localhost' is not unique
- [Hadoop] - Mapreduce自定义Counter
- Web指纹识别目的Discuz识别+粗糙的版本演绎
- ZMMR103-数据批量导入
- ZMMR104-预留单批量删除及恢复
- Win7系统如何批量删除C盘log日志文件?Win7系统批量删除C盘log日志文件的方法
- 如何建立个人博客?
- 如何建立个人博客?
- linux c程序调用lua代码的实例
- android中color的用法及十六进制编码大全
- java 中文简体繁体互相转换
- Linux-CentOS7 安装VMware Workstation 12
- Android学习——Intent传递复杂数据类型
- Web前端开发技术栈
- memcached(二)--原理
- 监控系统选型之监控功能浅析
- 排序算法总结
- Eclipse启动出现an error has occurred see the log file的解决方法
- Android Studio无法识别测试用例
- Undefined symbols for architecture armv7: "_OBJC_CLASS_$_CTTelephonyNetworkInfo", referenced from: