Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 使用3.0 SDK获取Facebook个人资料图片_Iphone_Ios_Facebook - Fatal编程技术网

Iphone 使用3.0 SDK获取Facebook个人资料图片

Iphone 使用3.0 SDK获取Facebook个人资料图片,iphone,ios,facebook,Iphone,Ios,Facebook,我在使用新的Facebook SDK获取用户的个人资料图片时遇到问题。这里的所有答案都使用旧SDK中不再有效的方法 我曾尝试使用Facebook教程中推荐的FBProfilePictureView,但这张图片无法缓存,我认为它无法转换为UIImage 有人能提供一些帮助吗?谢谢 使用链接: https://graph.facebook.com/me?fields=picture 获取当前用户的个人资料图片 Facebook提供了一个新的工具,当你想尝试查询或检查返回的输出时,它会派上用场 这

我在使用新的Facebook SDK获取用户的个人资料图片时遇到问题。这里的所有答案都使用旧SDK中不再有效的方法

我曾尝试使用Facebook教程中推荐的FBProfilePictureView,但这张图片无法缓存,我认为它无法转换为UIImage

有人能提供一些帮助吗?谢谢

使用链接:

https://graph.facebook.com/me?fields=picture 获取当前用户的个人资料图片

Facebook提供了一个新的工具,当你想尝试查询或检查返回的输出时,它会派上用场


这里有一个指向的链接。

好的,我终于通过以下方式得到了这个链接:

imageData = [[NSMutableData alloc] init]; // the image will be loaded in here
NSString *urlString = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large", user.id];
NSMutableURLRequest *urlRequest =
[NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
                                     cachePolicy:NSURLRequestUseProtocolCachePolicy
                                 timeoutInterval:2];

// Run request asynchronously
NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest
                                                                              delegate:self];
if (!urlConnection)
        NSLog(@"Failed to download picture");
然后我使用
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-(void)connectiondFinishLoading:(NSURLConnection*)connection
将图像放在一起。

用于缓存图像。请求图像的URL应为

NSString *string = [NSString stringWithFormat:@"https://graph.facebook.com/%@?fields=picture", userid];

如果您的问题与“self.userPofilePicture.profileID=user.id;”有关

然后self.userProfilePicture返回UIView,以便在其中查看和显示

不要忘记在Identity Inspector中添加类FBProfilePictureView以及[FBProfilePictureView类]到AppDelegate实现文件

我希望这会有所帮助。

我找到的最佳解决方案: 我使用了AFNetworking的UIImage。它处理重定向和缓存,所以您可以获取每个用户id的配置文件图片

NSString *imageUrl = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture", ((NSDictionary<FBGraphUser> *) [self.friends objectAtIndex: indexPath.row]).id];
[friendCell.imageView setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"profile.jpg"]];
NSString*imageUrl=[nsstringstringwithformat:@”http://graph.facebook.com/%@/picture“,((NSDictionary*)[self.friends objectAtIndex:indexPath.row]).id];
[friendCell.imageView setImageWithURL:[NSURL URLWithString:imageUrl]占位符图像:[UIImage ImageName:@“profile.jpg”];

将URL更改为:
NSString*string=[NSString stringWithFormat:@]后,我如何从该链接将其缓存到我的应用程序中https://graph.facebook.com/%@/图片”,用户ID]我通过NSURLConnection*urlConnection获得FB配置文件映像,但请让我知道如何在UIImageView上实现此功能我认为这是为了与FBLoginView配合使用,它是self.friends?
NSString *imageUrl = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture", ((NSDictionary<FBGraphUser> *) [self.friends objectAtIndex: indexPath.row]).id];
[friendCell.imageView setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"profile.jpg"]];