簡體   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