简体   繁体   English

我如何使用Facebook访问令牌?

[英]What do I do with the facebook access token?

I set up Facebook login with my swift, php, mysql ios app and am storing basic user info in NSUserdefaults, so I can check whether the user is logged in or not. 我使用swift,php,mysql ios应用程序设置了Facebook登录名,并将基本用户信息存储在NSUserdefaults中,因此我可以检查用户是否已登录。 But when reading the Facebook docs, I came across the Facebook token to check if the user is logged in. Would I/should I use this. 但是在阅读Facebook文档时,我碰到了Facebook令牌,以检查用户是否已登录。我是否应该使用它。 I assume not since when the user signs in through Facebook I would take the same route as regular sign in and just store the Facebook info in NSUserDefaults and just authorize through that. 我假设不是这样,因为当用户通过Facebook登录时,我会采用与常规登录相同的途径,只是将Facebook信息存储在NSUserDefaults中,然后通过它进行授权。

Access token is for authentication 访问令牌用于身份验证

Access token is required for getting further info of the user. 需要访问令牌才能获取用户的更多信息。 In few cases if your application contains both login login via Email of login via Facebook you need token. 在少数情况下,如果您的应用程序同时包含通过Facebook 登录电子邮件登录登录,则需要令牌。 like below you get data: 像下面这样您将获得数据:

if((FBSDKAccessToken.current()) != nil){
                    FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, email, picture.width(180).height(180)"]).start(completionHandler: { (connection, result, error) -> Void in
                        if (error == nil){
                            self.fbAccesstoken = FBSDKAccessToken.current().tokenString //save your access token and in result object you get "id,name, first_name, last_name, email, picture (180*180)"
                            completion(result as AnyObject,nil)
                        }
                    })
                }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM