Useful FBML code for your Facebook Page
Automatically Like a Page
While making a Facebook Page use the following anchor tag to get a user to become a fan of the Page with just one click.
<a ajaxify="/ajax/pages/fan_status.php?fbpage_id=[Your_Page_ID]&add=1&reload=1&preserve_tab=1&use_primer=1″ rel=”async-post”>Become a Fan</a>
where,
fbpage_id = [Your Page ID], you can get that from the URL of the Page.
reload=1, set to 0 if you don’t want to refresh the Page, text ‘You are a fan’ will show up.
To pop up a friend invite dialog, use the following,
<a href="#" ajaxify="/ajax/social_graph/invite_dialog.php?class=FanManager&node_id=[Your_page_ID]” rel=”dialog-post” >Invite Friends</a>
where,
node_id= [Your Page ID]
Update: This code no longer works as of March 2nd, 2010.
Update 2: The code seems to be working again, it’s hit and miss so try it out.
Update 3: It was back up for two days and now its no longer working. I’ve also added more FBML code samples for those visiting from Search Engines. Be sure to check out The Ultimate Guide to Creating Facebook Fan Pages.
FBML Pop-Up Dialogue
Add this code to your Facebook Page to get a Pop Up Dialogue.
<a href=”" clicktoshowdialog=”Code”>Click here to see a pop up box</a>
<fb:dialog id="Code">
<fb:dialog-title>Enter the title of your pop up box.
</fb:dialog-title>
<fb:dialog-content>
Enter some text for your pop-up.
</fb:dialog-content>
<fb:dialog-button type="button" value="Close" close_dialog="1"/>
</fb:dialog>
FBML Invite Friends
The following code adds a friend selector to your Facebook Page.
<fb:request-form method=”post” action=”http://www.facebook.com/YourPageURLGoesHere” content=”Description of Page
<fb:req-choice url=’http://www.facebook.com/YourPageURLGoesHere’ label=’View Page’ />” type=”Page” invite=”true”>
<fb:multi-friend-selector condensed=”true” selected_rows=”0″ style=”width: 190px;” />
<fb:request-form-submit />
</fb:request-form>
If you thought this was useful check out The Ultimate Guide to Creating Facebook Fan Pages.
You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.