NA000022 NA000022 - 1 year ago 63
Swift Question

Not getting photos from Facebook

I want to fetch all the photos from facebook account. But I am unable to fetch it. Whenever i request I get empty array.

@IBAction func shareFacebook(sender: FBSDKLoginButton) {
sender.readPermissions = ["public_profile", "email", "user_friends"]
sender.delegate = self
sender.loginBehavior = .Native

//Delegate Method
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!)
FBSDKGraphRequest.init(graphPath: "me/photos", parameters: ["fields":"age_range,name,first_name, last_name, picture.type(large)"], HTTPMethod: "get").startWithCompletionHandler { (con, res, err) in

//Output = <FBSDKAccessToken: 0x12fea99a0>
data = (

Answer Source

/me/photos requires the permission user_photos. Make sure you authorize the user with that permission:

sender.readPermissions = ["public_profile", "email", "user_friends", "user_photos"]

If it still does not work, make sure you are trying as App Admin and read about Login Review:

Also, the /me/photos endpoint does not have fields like age_range, name, first_name and so on. That would be the /me endpoint only.