个人资料图片来自Facebook图表api

时间:2015-04-07 06:43:00

标签: ios objective-c iphone

我没有收到我的脸谱资料图片。 我得到我的脸书id = 739615472819667;

+(NSDictionary *)getImage:(NSString *)idd
{
    NSLog(@"%@",idd);
    NSDictionary *imageDictionary;

    if ([self hasInternetConnection] == YES) {
               NSString *urlStr=[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture",idd];
                NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
        imageDictionary  =  [self sendRequest:request];
         NSLog(@"%@",imageDictionary);
        return imageDictionary;

    }
}

2 个答案:

答案 0 :(得分:3)

试试这个

 NSString *userImageURL = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large", pass your ID];

// pass this String where U need, like convert URL to Image or else

可以使用的其他查询参数是:

  • type :small,normal,large,square
  • width :<值>
  • 身高:<值>
    • 同时使用 width height 来获取裁剪的宽高比填充图像

我得到了你的ID好友的输出,例如

https://graph.facebook.com/739615472819667/picture?type=large

enter image description here

答案 1 :(得分:0)

它会起作用(用你的FBID替换FbID)。

`NSString * strProfilePicURL = nil;

if([[NSUserDefaults standardUserDefaults] objectForKey:@" FbID"]!= nil)

{

strProfilePicURL = [NSString stringWithFormat:@" https://graph.facebook.com/%@/picture",[[NSUserDefaults standardUserDefaults] objectForKey:@" FbID"]];

}

imgSelf = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL] URLWithString:strProfilePicURL]]];`