Apple app API for Apple apps with iFrame example?
I have a Facebook app like an iFrame pointing to a file on my own server. I followed http://wiki.developers.facebook.com/index.php/JavaScript_Client_Library and the first example, but nothing shows up in the error console in Firefox or in the textbox. This file works with other stuff than Facebook.
What's a simple example using the Facebook API to display the name of the person who is logged in? It's in an iFrame, so I can't use plain FBML stuff.
+2
source to share
1 answer
Here's a quick example from my application, slightly modified for simplicity and readability. I am using jQuery and jRails (for Ruby on Rails development) hence "$ (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>
+2
source to share