iOS无法在FBSDKGraphRequest中发送字典参数

时间:2016-07-29 17:05:32

标签: ios objective-c iphone facebook

我正试图通过我的应用程序以合理的质量获取Facebook用户的个人资料照片。默认情况下,没有任何参数,请求路径" me?fields = picture"获取小的但使用带有键的参数字典@"键入"和价值@"大"将检索大的。然而,api似乎忽略了参数。

FBSDKGraphRequest* picRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=picture" parameters:[NSDictionary dictionaryWithObject:@"small" forKey:@"type"] HTTPMethod:@"GET"];

[picRequest startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

        if (result) {

            NSString* profilePictureURLString = [[[(NSDictionary*) result objectForKey:@"picture"] objectForKey:@"data"] objectForKey:@"url"];
            NSURL* profilePictureURL = [NSURL URLWithString:profilePictureURLString];
            NSData* profilePictureData = [NSData dataWithContentsOfURL:profilePictureURL];      
       }]; 

结果数据始终是50x50像素的小图片。

是的,有人能帮帮我吗?谢谢!

1 个答案:

答案 0 :(得分:0)

您可以设置图片的大小,如picture.width(float).height(float)。请参阅以下示例:

FBSDKGraphRequest* picRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=picture.width(200).height(200)"
                                                              parameters:nil
                                                              HTTPMethod:@"GET"];

您可以将请求测试到Graph API Explorer