Reputation: 957
When using Facebook's graph explorer graph paths I was able to get the user's cover photo URL using:
connection.add(GraphRequest(graphPath: "/me/albums")) { httpResponse, result in ...
then finding the id with the name: "Cover Photos" and using the graph request:
connection.add(GraphRequest(graphPath: ("/" + id + "/photos"))) { httpResponse, result in
then taking the first and most recent id from the Cover Photos album
then finally use the graph request:
connection.add(GraphRequest(graphPath: ("/" + id + "/picture"))) { httpResponse, result in
to get the URL of the cover photo.
However, when performing the final graph request, I get the error:
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}
I haven't been able to use NSURLRequest nor NSURLSession to get the URL. To be clear, when using "/" + id + "/picture" in the Facebook Graph Explorer, I was able to get the cover photo URL. However, it does not work with iOS. I believe I have the correct permissions in:
let loginButton = LoginButton(readPermissions: [ .publicProfile, .userPhotos ])
Upvotes: 0
Views: 233
Reputation: 957
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)
}
}
Upvotes: 1