我想用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