我需要得到我所有朋友的名单:
我找到了这段代码:
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)")
}
}
但作为回报我收到了这个错误:
错误可选(错误域= NSURLErrorDomain代码= -1002"不支持 URL" 的UserInfo = {NSErrorFailingURLStringKey =(空)的access_token = EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52svqei6SHvxi3W9vcynSI8hPQBBSawND9NHQif0wYIPuHIpbzl6ErBErvk6nm4ysMo1ZA0BFHVmflVYZD&安培;格式= JSON&安培; include_headers =假安培; SDK = IOS, NSErrorFailingURLKey =(空)的access_token = EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52svqei6SHvxi3W9vcynSI8hPQBBSawND9NHQif0wYIPuHIpbzl6ErBErvk6nm4ysMo1ZA0BFHVmflVYZD&安培;格式= JSON&安培; include_headers =假安培; SDK = IOS, NSLocalizedDescription =不支持的URL,NSUnderlyingError = 0x7a6285b0 {错误域= kCFErrorDomainCFNetwork代码= -1002"不支持的URL" 的UserInfo = {NSErrorFailingURLKey =(空)的access_token = EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52svqei6SHvxi3W9vcynSI8hPQBBSawND9NHQif0wYIPuHIpbzl6ErBErvk6nm4ysMo1ZA0BFHVmflVYZD&安培;格式= JSON&安培; include_headers =假安培; SDK = IOS, NSErrorFailingURLStringKey =(空)?=的access_token EAAZAaT5Yj9qQBABsXA5KGpwvGX6wIdgX6h9mLtzz6YtgjiOB12XwWxl1MrDJLtZChWSOOKXDiizZCu7uZAixBmqP97HYUXkeg3lkTeeeyjmvhZBOZBibrp2Exa9uZB7V5fflJTvISF2aqK94H7E52
答案 0 :(得分:9)
@CBroe是对的,这就是代码的样子
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()