I need to get all my friends list:
I found this code:
var fbRequestFriends: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "/{friend-list-id}", parameters: [AnyHashable : Any]())
fbRequestFriends.start { (connection, result, error) in
if error == nil && result != nil {
print("Request Friends result : \(result!)")
} else {
print("Error \(error)")
}
}
But in return I get this error:
Error Optional(Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSErrorFailingURLStringKey=(null)?access_token=EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52svqei6SHvxi3W9vcynSI8hPQBBSawND9NHQif0wYIPuHIpbzl6ErBErvk6nm4ysMo1ZA0BFHVmflVYZD&format=json&include_headers=false&sdk=ios, NSErrorFailingURLKey=(null)?access_token=EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52svqei6SHvxi3W9vcynSI8hPQBBSawND9NHQif0wYIPuHIpbzl6ErBErvk6nm4ysMo1ZA0BFHVmflVYZD&format=json&include_headers=false&sdk=ios, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x7a6285b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "unsupported URL" UserInfo={NSErrorFailingURLKey=(null)?access_token=EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52svqei6SHvxi3W9vcynSI8hPQBBSawND9NHQif0wYIPuHIpbzl6ErBErvk6nm4ysMo1ZA0BFHVmflVYZD&format=json&include_headers=false&sdk=ios, NSErrorFailingURLStringKey=(null)?access_token=EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52
@CBroe is right, this is how the code should look like
let params = ["fields": "id, first_name, last_name, name, email, picture"]
let graphRequest = FBSDKGraphRequest(graphPath: "/me/friends", parameters: params)
let connection = FBSDKGraphRequestConnection()
connection.add(graphRequest, completionHandler: { (connection, result, error) in
if error == nil {
if let userData = result as? [String:Any] {
print(userData)
}
} else {
print("Error Getting Friends \(error)");
}
})
connection.start()
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