【问题标题】:facebook integration Error 2500 OAuthException xcode 8 Swift 3facebook集成错误2500 OAuthException xcode 8 Swift 3
【发布时间】:2016-10-12 05:59:01
【问题描述】:

我正在研究 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 Code=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={ 身体 = { 错误 = { 代码 = 2500; "fbtrace_id" = "FmK/8QACfhe"; message = "必须使用活动访问令牌来查询有关当前用户的信息。"; 类型 = OAuthException; }; }; 代码 = 400; }}) 谁能帮我解决这个问题??

【问题讨论】:

  • 试试这个,FBSession.activeSession = fbSession。
  • 它没有在我的代码中设置

标签: swift3 facebook-login xcode8


【解决方案1】:

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith 结果: FBSDKLoginManagerLoginResult!, 错误: Error!) { print("点击登录按钮")

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"]!)
        }
})

}

【讨论】:

    猜你喜欢
    • 2017-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-15
    相关资源
    最近更新 更多