views:

76

answers:

1

Hi,

I want to display the context of a .txt file in an html file.

I know this would be very easy with PHP or javascript, but, to put you in context, I am building a content administrator for a Facebook page (Not app).

Facebook FBML is static and doest allow php and VERY limited javascript.

The first question would be if this is even possible (couldn´t find any decent answers by googling), and the second is the obvious how.

Thank you very much!

Trufa

EDIT: I saw this question http://stackoverflow.com/questions/3213103/is-it-possible-to-use-javascript-or-php-in-static-fbml

does this change mattbasta´s answer?

A: 

It sure is! You can use FBML to create an AJAX request back to your server and pull the TXT file in. You can basically load anything over AJAX that you otherwise would be able to load by just polling a URL. Check this out:

http://developers.facebook.com/docs/fbjs#ajax

Once you pull in the TXT file as a string in FBJS, just assign the string to an element and you're good as gold.

That should get you going. Good luck!

EDIT

Also, for the record, you can output your FBML from PHP (or any other language, for that matter) to create a dynamic FBML page. Just write FBML in the same way you would write HTML from your PHP script and it'll work exactly how you would expect it to!

EDIT 2

You can do something like this to create your FBML page:

<!-- FBML code here -->
<?php
echo file_get_contents("my_txt_file.txt");
?>
<!-- more FBML -->

Just point Facebook at that PHP file and it'll use the FBML that the PHP generates.

mattbasta
Will give it a good look thank you very much!
Trufa
@mattbasta can´t get it to work, i can´t seem to find how to "invoke" a .txt file
Trufa
@mattbaste please look at my edit too
Trufa
@Trufa Consider my edit above.
mattbasta
@mattbasta thanks for all your help but the problem I have is HOW do I "point Facebook at that PHP file", what function should I use etc.
Trufa
@Trufa If you're going to make the PHP file your canvas page, you would simply set the URL for the PHP file as your "Canvas URL" on the Facebook Integration tab of your application's settings. If the page is a sub-page of the canvas URL, you'd simply refer to it by its path relative to the canvas URL (just as you would do with a static FBML file).
mattbasta
Trufa
Are you trying to receive the value of the TXT file from a wall/status post? If so, that's not possible. You cannot include dynamic (or pseudo-dynamic) content in this way. It is not possible at this time.
mattbasta