没有从Facebook获取照片

时间:2016-05-09 08:41:14

标签: ios swift facebook-graph-api facebook-sdk-4.0

我想从Facebook帐户中获取所有照片。但我无法取得它。每当我要求我得到空阵列。

 @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 =     (
    );
}

2 个答案:

答案 0 :(得分:1)

/me/photos需要权限user_photos。确保您使用该权限授权用户:

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

如果仍然无效,请确保您尝试作为App Admin并阅读有关登录评论的信息:https://developers.facebook.com/docs/facebook-login/review

此外,/me/photos端点没有age_rangenamefirst_name等字段。那只是/me端点。

答案 1 :(得分:0)

emilia_clarke