我正在使用xcode 8 Swift 3中的facebook集成。 我使用了以下代码
let parameters = ["fields": "email, first_name, last_name, picture.type(large)"]
FBSDKGraphRequest.init(graphPath: "me", parameters: parameters).start { (connection, result, error) in
if error != nil{
print(error)
return
}
但我收到了以下错误。
可选(错误域= com.facebook.sdk.core代码= 8"(null)" UserInfo = {com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey = 0,com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey = 400,com.facebook.sdk:FBSDKErrorDeveloperMessageKey =必须使用活动访问令牌来查询有关当前用户的信息.com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode = 2500,com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey = { body = { error = { 代码= 2500; " fbtrace_id" =" FmK / 8QACfhe&#34 ;; message ="必须使用活动访问令牌来查询有关当前用户的信息。&#34 ;; type = OAuthException; }; }; 代码= 400; }}) 任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
func loginButton(_ loginButton:FBSDKLoginButton!,didCompleteWith result:FBSDKLoginManagerLoginResult!,error:Error!){ 打印("登录但是点击了#34;)
let graphRequest:FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"first_name, gender, last_name, email, picture.type(large)"])
graphRequest.start(completionHandler: { (connection, result, error) -> Void in
if ((error) != nil)
{
print("Error: \(error)")
}
else
{
let data:[String:AnyObject] = result as! [String : AnyObject]
print(data["first_name"]!)
print(data["last_name"]!)
print(data["email"]!)
print(data["id"]!)
print(data["gender"]!)
}
})
}