无法加载Facebook个人资料图片

时间:2016-01-18 09:54:23

标签: objective-c facebook sdk ios9

我在将个人资料图片从facebook上传到我的API并保存到Parse时遇到问题。此代码来自Udemy。我正在使用Xcode 7.2。

错误:

Socket

代码:

2016-01-18 10:14:15.296 MatchedUp[14381:5418567] Error in FB request Error Domain=com.facebook.sdk Code=5 "(null)" UserInfo={com.facebook.sdk:HTTPStatusCode=400, com.facebook.sdk:ErrorSessionKey=<PFReceptionist: 0x12663d2e0>, com.facebook.sdk:ParsedJSONResponseKey={
   body =     {
       error =         {
           code = 100;
           "fbtrace_id" = "FXTRrxOh0+c";
           message = "(#100) Tried accessing nonexisting field (photo) on node type (User)";
           type = OAuthException;
       };
   };
   code = 400;
}}

我知道如何解决这个问题? 非常感谢!

1 个答案:

答案 0 :(得分:2)

试试这个。

- (void)getFBProfilePicture {
   NSString *facebookId = @"yourFacebookId";
   NSString *imageUrl = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large&return_ssl_resources=1", facebookId];
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
     NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]];
     dispatch_async(dispatch_get_main_queue(), ^{
        self.imageView.image = [UIImage imageWithData:imageData];
     });
  });
}