views:

186

answers:

1

how do i code a facebook quote application taking its data from php/mysql page generating quotes randomely? i've already developed one, but it's using jquery which fbml doesn't support and since i'd like the profile tab i'd rather go for fbml instead of iframe.

anyone have any ideas on how to do this without jquery or using fbjs? thanks!

<!DOCTYPE html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<link rel="stylesheet" type="text/css" href="css/jquote.css" />
<!--<script type="text/javascript" src="scripts/jquery-1.4.2.js"></script>-->
<script type="text/javascript" src="fbjqry/utility.js"></script>
<script type="text/javascript" src="fbjqry/fjqry.js"></script>
<script type="text/javascript">
// On page load, fill the box with content.
$(document).ready(function() {
$("#quoteContainer").load("quote.php");
});

var auto_refresh = setInterval(
function ()
{
   $('#quoteContainer').load('quote.php');
}, 5000); // refresh every 10000 milliseconds
</script>

</head>

<div id="wrapper">
<div class="header">&nbsp;Quote of the Day</div>
<div id="quoteContainer">
</div>
</div>

</html>
+1  A: 

That's a pretty broad question, but basically you have two options with Facebook. You can make an FBML application, and have your client-side scripting limited to FBJS, or you can make an iframe application, and utilize whatever Javascript libraries you want.

The intermediate solution is to put iframes in your FBML pages using the <fb:iframe> tag. The iframes will let you use full Javascript, but of course you can't modify anything outside the iframe using code from inside it. It can be a good tool though, you just have to design your UI properly.

You mention that you use JQuery, but you don't really say what for. If you're worried about AJAX functionality, FBJS provides that. If you want fancy effects, then you might be out of luck, as FBJS can be pretty limiting.

Another thing to keep in mind is that profile tabs get their own URL, so they can be pointed to completely separate code than the main application. For example, if your main app is served from http://yourapp.com, in the Developer settings you can set the Profile Tab to be at http://yourapp.com/profiletab. There's no reason you couldn't serve out an iframe app as the main application, and just code up some FBML output for the Profile Tab.

zombat
i'm using jquery to get the quotes randomly from the php file. even if i code fbml output for the profile tab, how would i generate the quotes randomly without jquery?
fuz3d
i've posted the code, please check it out.
fuz3d
Well, instead of using jquery you could just put the quote inside the HTML output using PHP. Failing that, it looks like all that jQuery is doing is an ajax call (`.load()` is just an ajax call with some special handling done to the result), so implementing that in FBJS wouldn't be too difficult.
zombat
@zombat, can you give me some pointers as to how to go about doing it in fbjs. appreciated. thanks.i tried using fbjqry, but that doesn't work.
fuz3d

related questions