I am trying to implement a facebook graph request just as described on their developer´s doc page (https://developers.facebook.com/docs/swift/graph). Xcode 10.2.1, swift 5.
But I keep getting the following error:
Contextual closure type '(GraphRequestConnection?, Any?, Error?) -> Void' expects 3 arguments, but 2 were used in closure body
I have done a lot of research and tried to fill in several arguments but I simply cannot figure out what the missing third argument might be.
import FBSDKCoreKit
let connection = GraphRequestConnection()
connection.add(GraphRequest(graphPath: "/me")) { httpResponse, result in
switch result {
case .success(let response):
print ("Graph Request succeeded: \(resonse)")
case .failed (let error):
print ("Graph Request failed: \(error)")
}
}
connection.start()
Can someone help please?
API Version Deprecations: As part of Facebook's Graph API and Marketing API, please note the upcoming deprecations: August 3, 2021: Graph API v3. 3 will be deprecated and removed from the platform. August 25, 2021 Marketing API v9.
The simplest way to get a copy of the User Profile object is to access the /me endpoint: FB. api('/me', function(response) { }); This will this will return the users name and an ID by default.
I got the same behavior. I am not that experienced in Swift and the Facebook Graph API and I'm not sure if it is a good solution but, currently (until I find a better solution), for me works:
connection.add(GraphRequest(graphPath: "/me", parameters: ["fields":"email"])) { httpResponse, result, error in
if error != nil {
NSLog(error.debugDescription)
return
}
// Handle vars
if let result = result as? [String:String],
let email: String = result["email"],
let fbId: String = result["id"] {
// internal usage of the email
self.userService.loginWithFacebookMail(facebookMail: email)
}
}
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