简体   繁体   中英

Profile Pic not Getting From Facebook graph api

I am not getting my facebook profile pic . I am getting my 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

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

在此处输入图片说明

It will work (Replace FbID with your 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]]];`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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