NA000022 NA000022 - 2 years ago 79
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download