在iOS6中获取用户个人资料图片? [英] Getting user profile picture in iOS6?

查看:208
本文介绍了在iOS6中获取用户个人资料图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过:

meurl = [NSURL URLWithString:@"https://graph.facebook.com/me/picture"];
SLRequest *imageReq =[SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:meurl parameters:nil];
imageReq.account = self.facebookAccount;

[imageReq performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
    if (error) {
        NSLog(@"error -%@", [error debugDescription]);
    }else{
        NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

        NSLog(@"image -%@", meDataString);
    }


}];

但我得到 image - (nil)

我有一个其他的请求,就在用户信息的代码之上,我得到所有的数据就好了。

I have an other request right above that code for user info and I get all the data just fine.

推荐答案

@shannoga - 你几乎在正确的道路上。在您的请求中,您不必使用Facebook用户标识。为此,请求获取用户详细信息 - https://graph.facebook.com/me 。然后从该请求中,从json解析的响应数据中获取处理程序中的用户ID。使用此用户ID,发出此请求 - https://graph.facebook.com/userid/picture
在响应中,您将获得您的个人资料图像数据的响应数据。

@shannoga - You are almost on the right path. Instead of me in your request, you have to use the Facebook user id. For that first make this request to get the user details - https://graph.facebook.com/me . Then from this request, get the user id in the handler from the json parsed response data. Using this user id, make this request - https://graph.facebook.com/userid/picture. In the response, you will get the response data which is your profile image data.

这篇关于在iOS6中获取用户个人资料图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆