Jecky Jecky - 6 months ago 37
Swift Question

High Resolution Images from facebook

This is how I am getting photo albums and pictures from the album.

let connectionPhotos = FBSDKGraphRequestConnection()
let requestPhotos = FBSDKGraphRequest(graphPath: String(format:"/%@/photos",albumID), parameters: ["fields":"picture.type(large)"], HTTPMethod: "GET")
connectionPhotos.addRequest(requestPhotos) { (connection:FBSDKGraphRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
if(error != nil){
print(error)
self.btnFacebook.userInteractionEnabled = true
connectionPhotos.cancel()
}else{
connectionPhotos.cancel()
self.arrImages = result["data"] as! Array<Dictionary<String, String>>

if let userWSRequestKey = TRUserModel.SharedInstance()?.userWSRequestKey{
if userWSRequestKey != X_API_DEFAULT_KEY{
self.callSignInWS(dict)
} else{
JSONParser.sharedInstance.parseRequestKeyWithURL("", requestPrm: ["string":"string"], completionHandler: { (response) -> Void in
if response["status"] as! Int == 1 {
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.callSignInWS(dict)
})
} else {
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.showAlertView(INTERNET_PROBLEM)
})
}
})
}
} else{
JSONParser.sharedInstance.parseRequestKeyWithURL("", requestPrm: ["string":"string"], completionHandler: { (response) -> Void in
if response["status"] as! Int == 1 {
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.callSignInWS(dict)
})
} else {
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.showAlertView(INTERNET_PROBLEM)
})
}
})
}
}
}
connectionPhotos.start()



  • Simply I have 414*414 pixel size image and I am getting images through above code are small So it's going to blur in my application. So, how can I get large images.

  • Any Suggestion ?


Answer

with this graph path

GET /v2.6/{photo-id}/?fields=images

i'm getting an array of images of different sizes.

example:

{ "height": 1365, "source": "...", "width": 2048 }, { "height": 960, "source": "...", "width": 1440 }, { "height": 720, "source": "...", "width": 1080 }

hope this helped :D