views:

58

answers:

2

Using jquery (javascript) need to display facebook user name in html page using facebook user id. I am not using facebook api. Any one have any idea.

+1  A: 

You need to use the Facebook API as Facebook needs to authenticate your application's requests for user data. (http://developers.facebook.com/docs/api#authorization)

I recommend using the Graph API (http://developers.facebook.com/docs/api), but it takes a bit of work getting started.

I use the PHP SDK (http://github.com/facebook/php-sdk/), though others also exist and you can find them in the Facebook Documentation.

However, to answer your question better, If you have your authorization token you can make calls for example:

https://graph.facebook.com/me?access_token=<Your Access token>

would return a JSON object containing your basic information, including your name, birthday, and basically everything that appears on your profile.

Before doing anything you MUST register your own application at www.facebook.com/developers/

(Edit: I was not aware FBML was being phased out)

KennyCason
+1  A: 

Without using the facebook API (Graph API or older facebook REST API) either javascript or PHP there's no way you can achive this.

Facebook needs to authenticate your application before you ask for data.

You can use fb:name from FBML (Facebook Markup Language) to achive it easily. But as recoomended, you should not use FBML for new applications since the recommended way is the new Graph API. FBML is in the process of being deprecated.

Using the new Graph API you can get the JSON object for the user by fetching https://graph.facebook.com/{userID}

Carlos Muñoz
Yeah, I wasn't aware FBML was being phase out completely. But I do agree Graph API is the way to go, that's what we use
KennyCason
Thank you Carlos and Kenny!!
Elankeeran
np, hope you enjoy integrating social media into your websites, it makes them much more personal and enjoyable!
KennyCason