Reputation: 3647
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!)
{
print(result.token)
FBSDKGraphRequest.init(graphPath: "me/photos", parameters: ["fields":"age_range,name,first_name, last_name, picture.type(large)"], HTTPMethod: "get").startWithCompletionHandler { (con, res, err) in
print(res)
}
}
//Output = <FBSDKAccessToken: 0x12fea99a0>
{
data = (
);
}
Upvotes: 0
Views: 57
Reputation: 73984
/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: https://developers.facebook.com/docs/facebook-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.
Upvotes: 1
Reputation: 1607
FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id,interested_in,gender,birthday,email,age_range,name,picture.width(480).height(480)"]).startWithCompletionHandler({ (connection, result, error) -> Void in
print(result)
})
Upvotes: 0