Why is it giving me the error 2015-09-14 20:56:31.773 Musec[7207:3288153] FBSDKLog: starting with Graph API v2.4, GET requests for /me should contain an explicit "fields" parameter
I am trying to access user information like friends, email, etc. How do I fix the error? Below is the login plus the permissions to get access to user info.
@IBAction func loginWithFB(sender: AnyObject) {
var permissions = [ "public_profile", "email", "user_friends"]
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions, block: { (user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
println("User signed up and logged in through Facebook!")
self.performSegueWithIdentifier("success", sender: self)
//let params = ["fields": "name, email, friends"]
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "name, email, friends"])
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil)
{
// Process error
println("Error: \(error)")
}
else
{
//get username
let userName : NSString = result.valueForKey("name") as! NSString
println(userName)
//get Facebook ID
let email: NSString = result.valueForKey("email") as! NSString
println(email)
//get facebook friends who use app
let friendlist: NSString = result.valueForKey("friends") as! NSString
println(friendlist)
}
})
} else {
println("User logged in through Facebook!")
self.performSegueWithIdentifier("success", sender: self)
}
} else {
println("Uh oh. The user cancelled the Facebook login.")
}
})
}
I don't think that FBSDKLog: starting with Graph API v2.4, GET requests for /me should contain an explicit "fields" parameter
is actually an error. It is just a Log. If you will run the code and set a break point you will find that, error is actually nil
and you will be able to successfully compile the code and see the else
portion of the code getting executed.
Now, you are trying to access the name
of Facebook user but not passing name
in the fields
. That is why you will get name
as null
. Pass name
as list of parameters.
let params = ["fields": "name, email, friends"] <----- This line
Or here:
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "name, email, friends"])
Now, you will be able to fetch name, email and friends
of the Facebook user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With