Here's a quick example straight from my application, slightly modified for simplicity and your readability. I use jQuery and jRails (for Ruby on Rails development), hence the "$(document).ready". if you need more explanation, just let me know.
<head>
<script src="/jquery.js" type="text/javascript"></script>
<script src="/jrails.js" type="text/javascript"></script>
<script type="text/javascript">
function getFriend(friendId){
// THIS IS WHAT YOU'RE PROBABLY INTERESTED IN
FB.Facebook.apiClient.fql_query("SELECT name, pic FROM user WHERE uid=" + friendId,
function(rows) {
alert("Hello, " + rows[0].name);
});
}
$(document).ready( function(){
getFriends();
});
</script>
</head>
<body>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
FB_RequireFeatures(["XFBML"], function(){ FB.Facebook.init("YOUR_API_KEY", "/xd_receiver.htm"); });
//]]>
</script>
</body>