Skip to content

Instantly share code, notes, and snippets.

@shrawan2015
Last active July 9, 2018 15:53
Show Gist options
  • Save shrawan2015/2c9c9a0247cd640c90c8d1b5d08fe8f1 to your computer and use it in GitHub Desktop.
Save shrawan2015/2c9c9a0247cd640c90c8d1b5d08fe8f1 to your computer and use it in GitHub Desktop.
let loginManager: FBSDKLoginManager = FBSDKLoginManager()
loginManager.logIn(withReadPermissions: ["user_link"], from: fromViewController) { (result, error) in
if error != nil{
return
}else if (result?.isCancelled)!{
//Handle cancelation
}else{
if (result?.grantedPermissions.contains("user_link"))!{
//success
getFBProfile()
}
}
}
func getFBProfile(){
let request = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, email, picture.type(large),link"])
let _ = request?.start(completionHandler: { (connection, result, error) in
guard let userInfo = result as? [String: Any] else { return }
if let publicProfileLink = userInfo["link"] as? String {
print("publicLink = \(publicProfileLink)")
// publicProfileLink to access profile.
}
})
}
//publicLink = https://www.facebook.com/app_scoped_user_id/YXNpZADpBWEhkNUEzX2JBd2NfRkpJRklNX2NIUzB0Vm1lOGN4bTlaektKbUFwb1I4SWJzenRPZAXFlZAUJFM2J0SzVHZAXAyOXdhN1ZACVi1VVXZAJdVhrcl9DTmhrX0swLWRRTGttTktMaFR2SGZAwVWZAOdmwwQWFh/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment