【问题标题】:How to retrieve an image from fbprofilepictureview and store this image into database如何从 fbprofilepictureview 检索图像并将此图像存储到数据库中
【发布时间】:2014-01-11 12:39:47
【问题描述】:

显示个人资料图片。

      self.userProfileImage.profileID = user.id;

但是

       for (NSObject *obj in [userProfileImage subviews]) {
        if ([obj isMemberOfClass:[UIImageView class]]) {
            UIImageView *objImg = (UIImageView *)obj;
            img_ProfilePictureImg.image = objImg.image;
            break;
        }
    }
    img_ProfilePictureImg.image=[UIImage imageWithContentsOfFile:profileImage];

我没有得到 ---fbprofilepicture

     UIImage *img_Profile = --------.imageView.image; // How to get that image view 
     NSData *dataOfProfilePic = UIImagePNGRepresentation(img_Profile);

【问题讨论】:

    标签: ios objective-c facebook ipad


    【解决方案1】:

    https://graph.facebook.com/username/picture?redirect=true

    使用此网址,您可以获得个人资料图片。

    在 Facebook Delegate loginViewFetchedUserInfo 中,您可以获得用户个人资料图片的图片 url

     - (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                                user:(id<FBGraphUser>)user 
    {
    
    NSString *imageUrl=[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?redirect=true", user.username];
    
    }
    

    【讨论】:

    • 谢谢。我明白了。但我有一个疑问。那就是我必须将此图像存储到我的数据库中。如何将此字符串转换为 nsdata。
    • 您应该将图片网址存储在数据库中而不是图片中。
    • user.username 为我返回 null。知道为什么吗?
    • 我设法使用 user.id 查询图形 API,它似乎工作
    猜你喜欢
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 2015-03-16
    • 2011-08-03
    • 1970-01-01
    • 2018-03-03
    相关资源
    最近更新 更多