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.
Asked
Active
Viewed 786 times
1 Answers
-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!!!
![](../../users/profiles/3514769.webp)
Saqib Omer
- 4,917
- 7
- 46
- 65