Why am I getting this error while accessing Facebook user information?

Why does this give me an 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" parameterI'm trying to access user information, such as friends, email, etc. How to fix the error? The following is the login and permissions to access user information.

@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.")
        }
    })
}
+4
source share
1 answer

I do not think that FBSDKLog: starting with Graph API v2.4, GET requests for /me should contain an explicit "fields" parameteris actually a mistake. This is just a magazine. If you run the code and set a breakpoint, you will find that it is actually a mistake nil, and you can successfully compile the code and see part of elsethe code that is being executed.

name Facebook, name fields. name null. name .

let params = ["fields": "name, email, friends"] <----- This line

:

let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "name, email, friends"])

name, email and friends Facebook.

+7

Source: https://habr.com/ru/post/1607376/


All Articles