简体   繁体   English

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

[英]Profile Pic not Getting From Facebook graph api

I am not getting my facebook profile pic . 我没有得到我的Facebook个人资料照片。 I am getting my facebook id =739615472819667; 我正在获取我的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;

    }
}

try this 尝试这个

 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

Other query parameters that can be used are: 可以使用的其他查询参数是:

  • type : small, normal, large, square 类型 :小,普通,大,正方形
  • width : < value > 宽度 :<值>
  • height : < value > 高度 :<值>
    • Use both width and height to get a cropped, aspect fill image 同时使用宽度高度来获取裁剪的纵横比填充图像

I got the output for your ID friend, example 我得到了您的ID朋友的输出,例如

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

在此处输入图片说明

It will work (Replace FbID with your FBID). 它将起作用(用您的FBID替换FbID)。

`NSString *strProfilePicURL = nil; NSString * strProfilePicURL = nil;

if ([[NSUserDefaults standardUserDefaults]objectForKey:@"FbID"]!=nil) 如果([[NSUserDefaults standardUserDefaults] objectForKey:@“ FbID”]!= nil)

{ {

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

} }

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

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

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