我在获取封面个人资料图片时遇到困难...
这里我得到了个人资料图像:
let userProfile = "https://graph.facebook.com/" + userId + "/picture?type=large"
let profilePictureUrl = NSURL(string: userProfile)
let profilePictureData = NSData(contentsOfURL: profilePictureUrl!)
if (profilePictureData != nil) {
let profileFileObject = PFFile(data:profilePictureData!)
currentUser.setObject(profileFileObject!, forKey: "profilePicture")
}
效果很好。
现在我正在尝试获取封面图片:
let coverPicture = "https://graph.facebook.com/" + userId + "/cover?type=large"
let coverPictureUrl = NSURL(string: coverPicture)
let coverPictureData = NSData(contentsOfURL: coverPictureUrl!)
if (coverPictureData != nil) {
let coverFileObject = PFFile(data:profilePictureData!)
currentUser.setObject(coverFileObject!, forKey: "coverPicture")
}
但这似乎不起作用?!
如果有人可以帮忙,请帮忙:)
最佳答案
自从我使用 Graph Api 以来已经有一段时间了,但据我所知,即使 API 中有一个 cover
字段,您也无法直接访问用户的封面照片。
我能想到的最好的方法是请求用户的相册:
"https://graph.facebook.com/" + userId + "/albums"
在响应对象中,您将找到一个名为“Cover Photos”的相册:
"created_time": "2016-01-01T20:00:00+0000",
"name": "Cover Photos",
"id": "123456789101112"
使用{id)/picture
您可以获得封面照片。
希望这对您有帮助!
关于ios - FBSDKGraphRequest 如何获取个人资料封面照片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35489124/