我想用swift 3.0將Facebook登錄集成到iOS 10應用程序中。 我得到錯誤代碼2500爲設置在FacebookSDK到應用程序後如下所示:錯誤代碼2500在Swift 3.0上的Facebook登錄
錯誤代碼在控制檯上:
body = {
error = {
code = 2500;
"fbtrace_id" = FpAkfsaBAFc;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
};
code = 400;
}})
loginButton功能上loginViewController:
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
fetchProfile()
print("@@@@Completed [email protected]@@@")
}
在loginVC上獲取Facebook個人資料功能:
func fetchProfile() {
let parameters = ["fields": "email, first_name, last_name, picture.type(large)"]
FBSDKGraphRequest(graphPath: "me", parameters: parameters).start(completionHandler: { (connection, user, requestError) -> Void in
if requestError != nil {
print(requestError)
print("There are some error during getting the request from fb")
return
}
self.email = (user?["email"] as? String)!
self.firstName = (user?["first_name"] as? String)!
self.lastName = (user?["last_name"] as? String)!
self.nameLabel.text = "\(self.firstName) \(self.lastName)"
print("My fbname is " + self.firstName)
print(self.lastName)
var pictureUrl = ""
if let picture = user?["picture"] as? NSDictionary, let data = picture["data"] as? NSDictionary, let url = data["url"] as? String {
pictureUrl = url
print(pictureUrl)
}
})
}
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}
本來上搜索堆棧溢出類似的問題,但不工作的SWIFT 3.0,將不勝感激,如果任何人都可以在這個問題上,謝謝指教,有一個很好的天!
注意謝謝! – aznelite89