Facebook, javascript: Function with userID as parameter that returns name

It is possible to make a javascript function with an user id as parameter, that will RETURN the user's name?

Answers


Since the FB.api call is asynchronous, it's a little tricky to get it to simply return a user name. Depending on what you wanted to do with the name (populate a text field, display to the user, etc) you could pass in a callback function to be called once the name was retrieved. Something like this?

function getName(userId, callbackFunction) {
    FB.api('/' + userId, function(response) {

        callback(response.name)
    })
}

and you would use it like this

getName(YOUR_USER_ID, function(name) {
    alert(name)
})

Need Your Help

Random Label value in a UITextField

ios iphone objective-c random uitextfield

I'm trying to make two UILabel randomly. The contents of the label are int I also try as soon as the input in the UITextField is correct to give the two UILabel new values. My question is: How can ...

How create drop down menu, use LWUIT? What solutions exist?

java-me lwuit lwuit-form lwuit-button lwuit-dialog

I need to create drop down menu (see the picture). What methods are there? What should I use?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.