3

I've been able to login and get the first name, last name, email, and profile picture url in Xcode 6.1.1 with swift. I haven't been able to figure out how to get the urls or pull the images from a user, even though I have the user_photos Permission. Any help would be greatly appreciated.

user2592989
  • 819
  • 1
  • 7
  • 4

1 Answers1

-1

You need to make request to graph api that will return you JSON in response to your request. For example if you want to get name, profile picture (it will give you url for profile picture) and id you can make request in your viewDidLoad() as follows

FBRequestConnection.startWithGraphPath("me?fields=id,name,picture", completionHandler: {(connection: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in
        if (result? != nil) {
            NSLog("error = \(error)")

            println(result)
        }
        } as FBRequestHandler)

to set a label text to facebook name you can use

 var resultdict = result as? NSDictionary
            if let name = resultdict?["name"] as? String {

                self.YOUR_LABEL.text = name //name is response object in "result" dictionary

            }

Cheers!!!

Saqib Omer
  • 4,917
  • 7
  • 46
  • 65