我无法使用以下代码获取用户的出生日期。我缺少什么?
if FBSDKAccessToken.currentAccessToken() != nil {
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"email,name,birthday"])
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
print(" result >>>>>>>>>> \(result) ")
})
}
答案 0 :(得分:0)
我这样做了:
class loginViewController: UIViewController,FBSDKLoginButtonDelegate {
@IBOutlet var buttonFacebook: FBSDKLoginButton!
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
self.configureFacebook()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func configureFacebook()
{
buttonFacebook.readPermissions = ["public_profile", "email", "user_friends", "user_birthday"];
buttonFacebook.delegate = self
buttonFacebook.loginBehavior = .Native
FBSDKProfile.enableUpdatesOnAccessTokenChange(true)
}
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!){
FBSDKGraphRequest.init(graphPath: "me", parameters: ["fields":"email, birthday, first_name, last_name, picture.type(large)"]).startWithCompletionHandler { (connection, result, error) -> Void in
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!){
let loginManager: FBSDKLoginManager = FBSDKLoginManager()
loginManager.logOut()
}
}