Facebook iOS SDK和swift:如何获取用户的个人资料图片 [英] Facebook iOS SDK and swift: how get user's profile picture
问题描述
在登录期间,我请求public_profile权限:
FBSession.openActiveSessionWithReadPermissions([public_profile],allowLoginUI:true ,completionHandler:{
...
...
所以我要求用户的信息:
FBRequestConnection.startForMeWithCompletionHandler {(connection,user,error) - > Void in
..
...
为什么用户对象不包含个人资料图片?我可以获得用户个人资料图片吗?它不是public_profile的一部分?
我收到以下信息:
2015-01-25 01:25:18.858测试[767:23804] {
first_name= xxx;
gender = xxx;
id = xxxxxxxxx;
last_name= xxxxxx;
link =https://www.facebook.com/app_scoped_user_id/xxxxxxxxx/;
locale =xxxxx;
name =xxxxxxx xxxxxxx;
timezone = 1;
updated_time=2013-12-21T18:45:29 + 00 00;
verified = 1;
}
PS:xxx为隐私
个人资料图片实际上是公开的,您只需将用户ID添加到Facebook的指定个人资料图片网址地址,例如:
var userID = user [id] as NSString
var facebookProfileUrl =http://graph.facebook.com/\(userID)/picture ?type = large
这个特定的url地址应该返回用户的个人资料图片的大版本,但还有几个照片选项可用文档。
i have integrated Facebook sdk in Xcode 6 (with swift). During the login i request the public_profile permission:
FBSession.openActiveSessionWithReadPermissions(["public_profile"], allowLoginUI: true, completionHandler: {
...
...
So i request the user's information:
FBRequestConnection.startForMeWithCompletionHandler { (connection, user, error) -> Void in
...
...
Why the user object doesn't contain the profile picture? How can i get the user profile picture? It's not part of the public_profile?
I get the following information:
2015-01-25 01:25:18.858 Test[767:23804] {
"first_name" = xxx;
gender = xxx;
id = xxxxxxxxx;
"last_name" = xxxxxx;
link = "https://www.facebook.com/app_scoped_user_id/xxxxxxxxx/";
locale = "xxxxx";
name = "xxxxxxx xxxxxxx";
timezone = 1;
"updated_time" = "2013-12-21T18:45:29+0000";
verified = 1;
}
P.S: xxx for privacy
The profile picture is in fact public and you can simply by adding the user id to Facebook's designated profile picture url address, ex:
var userID = user["id"] as NSString
var facebookProfileUrl = "http://graph.facebook.com/\(userID)/picture?type=large"
This particular url address should return the "large" version of the user's profile picture, but several more photo options are available in the docs.
这篇关于Facebook iOS SDK和swift:如何获取用户的个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!