2016-10-12 32 views
0

我工作的facebook集成在Xcode 8斯威夫特3. 我用下面的代碼facebook集成錯誤2500 OAuthException的Xcode 8斯威夫特3

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 
     } 

但我得到下面的錯誤。

Optional(Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An active access token must be used to query information about the current user., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=2500, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={ body = { error = { code = 2500; "fbtrace_id" = "FmK/8QACfhe"; message = "An active access token must be used to query information about the current user."; type = OAuthException; }; }; code = 400; }}) can anyone help me out this ??

+0

試試這個,FBSession.activeSession = fbSession。 – KAR

+0

它沒有在我的代碼中設置 –

回答

1

FUNC loginButton(_ loginButton:FBSDKLoginButton!didCompleteWith結果:FBSDKLoginManagerLoginResult!錯誤:錯誤!){ 打印( 「登錄buttoon點擊」)

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

}