繁体   English   中英

个人资料照片未从Facebook图形API获取

[英]Profile Pic not Getting From Facebook graph api

我没有得到我的Facebook个人资料照片。 我正在获取我的Facebook 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;

    }
}

尝试这个

 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

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

  • 类型 :小,普通,大,正方形
  • 宽度 :<值>
  • 高度 :<值>
    • 同时使用宽度高度来获取裁剪的纵横比填充图像

我得到了您的ID朋友的输出,例如

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

在此处输入图片说明

它将起作用(用您的FBID替换FbID)。

NSString * strProfilePicURL = nil;

如果([[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]]]];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM