Guest User

Untitled

a guest
Oct 18th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. @IBOutlet weak var userFullName: UILabel!
  2. @IBOutlet weak var userProfileImage: UIImageView!
  3.  
  4.  
  5. override func viewDidLoad() {
  6. super.viewDidLoad()
  7.  
  8. userFullName.text = ""
  9.  
  10. if let _ = FBSDKAccessToken.current()
  11. {
  12. fetchUserProfile()
  13. }
  14.  
  15. }
  16.  
  17. override func didReceiveMemoryWarning() {
  18. super.didReceiveMemoryWarning()
  19.  
  20. }
  21.  
  22.  
  23. func fetchUserProfile()
  24. {
  25. let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id, email, name, picture.width(200).height(200)"])
  26.  
  27. graphRequest.start(completionHandler: { (connection, result, error) -> Void in
  28.  
  29. if ((error) != nil)
  30. {
  31. print("Error took place: (error)")
  32. }
  33. else
  34. {
  35. print("Print entire fetched result: (result)")
  36.  
  37. let fbData:[String:AnyObject] = result as! [String : AnyObject]
  38.  
  39. let userName : NSString? = fbData["name"]! as? NSString
  40. let facebookID : NSString? = fbData["id"]! as? NSString
  41.  
  42. if let imageURL = ((fbData["picture"] as? [String: Any])?["data"] as? [String: Any])?["url"] as? String {
  43. //Download image from imageURL
  44. }
  45.  
  46. }
  47. })
  48. }
Add Comment
Please, Sign In to add comment