我已经阅读了很多关于从Facebook获取信息的教程,但到目前为止我都失败了.我只是想从Facebook获取用户名和个人资料图片.
- (IBAction)login:(id)sender {
[FBSession openActiveSessionWithReadPermissions:@[@"email",@"user_location",@"user_birthday",@"user_hometown"]
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
switch (state) {
case FBSessionStateOpen:
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (error) {
NSLog(@"error:%@",error);
} else {
// retrive user's details at here as shown below
NSLog(@"FB user first name:%@",user.first_name);
NSLog(@"FB user last name:%@",user.last_name);
NSLog(@"FB user birthday:%@",user.birthday);
NSLog(@"FB user location:%@",user.location);
NSLog(@"FB user username:%@",user.username);
NSLog(@"FB user gender:%@",[user objectForKey:@"gender"]);
NSLog(@"email id:%@",[user objectForKey:@"email"]);
NSLog(@"location:%@", [NSString stringWithFormat:@"Location: %@\n\n",
user.location[@"name"]]);
}
}];
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed: …Run Code Online (Sandbox Code Playgroud) 我正在尝试检索配置文件图片的链接...到目前为止图形API调用:
[facebook requestWithGraphPath:@"me/picture" andDelegate:self];
Run Code Online (Sandbox Code Playgroud)
将图像本身作为数据返回.当我打电话时:
[facebook requestWithGraphPath:@"me/picture" andDelegate:self];
Run Code Online (Sandbox Code Playgroud)
我确实得到了一个包含每个链接的图片.反正有没有为个人资料图片获得某种类似的东西,至少只是链接...或者它不可能吗?如果有人已经通过这个,请告诉我.
干杯,
萨米.