Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @IBOutlet weak var userFullName: UILabel!
- @IBOutlet weak var userProfileImage: UIImageView!
- override func viewDidLoad() {
- super.viewDidLoad()
- userFullName.text = ""
- if let _ = FBSDKAccessToken.current()
- {
- fetchUserProfile()
- }
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- }
- func fetchUserProfile()
- {
- let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id, email, name, picture.width(200).height(200)"])
- graphRequest.start(completionHandler: { (connection, result, error) -> Void in
- if ((error) != nil)
- {
- print("Error took place: (error)")
- }
- else
- {
- print("Print entire fetched result: (result)")
- let fbData:[String:AnyObject] = result as! [String : AnyObject]
- let userName : NSString? = fbData["name"]! as? NSString
- let facebookID : NSString? = fbData["id"]! as? NSString
- if let imageURL = ((fbData["picture"] as? [String: Any])?["data"] as? [String: Any])?["url"] as? String {
- //Download image from imageURL
- }
- }
- })
- }
Add Comment
Please, Sign In to add comment