Matthew Steven Kelly

Facebook Social Plugins

April24

Facebook has recently introduced a new feature called social plugins: http://developers.facebook.com/plugins. These plugins are designed to integrate into websites and increase Facebook interaction with the internet.

Including things like the Recent Activity display (which is highly unlikely to display anything for this site):

But the real gem is being able to quickly add a “Like” button to all of your website’s pages.

For a quick add simply use the following HTML IFRAME text:

<iframe src="http://www.facebook.com/plugins/like.php?href=www.mysite.com&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:200px; height:25px"></iframe>

And change www.mysite.com to the URL of the page the like button is on.

Or if adding it to a PHP page:

<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}

echo '<iframe src="http://www.facebook.com/plugins/like.php?href='.curPageURL().'&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:200px; height:25px"></iframe>';

?>

Note: curPageURL function code from : http://www.webcheatsheet.com/php/get_current_page_url.php

posted under Technology and Me

Email will not be published

Website example

Your Comment: