无法从 Facebook 获取照片
Not getting photos from Facebook
我想从 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 = (
);
}
/me/photos
需要权限 user_photos
。确保您授予用户该权限:
sender.readPermissions = ["public_profile", "email", "user_friends", "user_photos"]
如果仍然无效,请确保您以应用程序管理员身份尝试并阅读有关登录审核的信息:https://developers.facebook.com/docs/facebook-login/review
此外,/me/photos
端点没有 age_range
、name
、first_name
等字段。那只是 /me
端点。
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)
})
我想从 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 = (
);
}
/me/photos
需要权限 user_photos
。确保您授予用户该权限:
sender.readPermissions = ["public_profile", "email", "user_friends", "user_photos"]
如果仍然无效,请确保您以应用程序管理员身份尝试并阅读有关登录审核的信息:https://developers.facebook.com/docs/facebook-login/review
此外,/me/photos
端点没有 age_range
、name
、first_name
等字段。那只是 /me
端点。
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)
})