在使用Facebook的图资源管理器图路径时,我可以使用以下方式获取用户的封面照片网址:
connection.add(GraphRequest(graphPath: "/me/albums")) { httpResponse, result in ...
然后找到名称为“ Cover Photos”的ID,并使用图形请求:
connection.add(GraphRequest(graphPath: ("/" + id + "/photos"))) { httpResponse, result in
然后从Cover Photos相册中获取第一个和最近的ID
然后最终使用图形请求:
connection.add(GraphRequest(graphPath: ("/" + id + "/picture"))) { httpResponse, result in
获取封面照片的网址。
但是,在执行最终图形请求时,出现错误:
UserInfo={com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Response is a non-text MIME type; endpoints that return images and other binary data should be fetched using NSURLRequest and NSURLSession}
我无法使用NSURLRequest或NSURLSession来获取URL。需要明确的是,在Facebook Graph Explorer中使用“ /” + id +“ / picture”时,我能够获得封面照片URL。但是,它不适用于iOS。我相信我拥有以下权限:
let loginButton = LoginButton(readPermissions: [ .publicProfile, .userPhotos ])
答案 0 :(得分:0)
func findCoverPhotoPicture(id: String) {
print("find cover url", id)
print("https://graph.facebook.com/" + id + "/picture")
let imgURL = "https://graph.facebook.com/" + id + "/picture"
do {
let covImg: UIImage = try UIImage(data: Data(contentsOf: URL(string: imgURL)!))!
self.picView.image = covImg
} catch {
print(error)
}
}