We’ve seen the facebook like button everywhere right? But the crappy thing is that you have to copy-and-paste the facebook iframe code that has to be then edited. Lets fix this right now.
I created a PHP function called facebook_like() which can be called anywhere where you want to show the facebook like button. For more info on the facebook like button go here :http://developers.facebook.com/docs/reference/plugins/like
I created a PHP function called facebook_like() which can be called anywhere where you want to show the facebook like button. For more info on the facebook like button go here :http://developers.facebook.com/docs/reference/plugins/like
COPY AND PASTE:
<?php
function facebook_like(){
function getAddress() //this function will show the URL you are on DONT EDIT
{
/*** check for https ***/
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
/*** return the full address ***/
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
$url = getAddress(); //your full URL for page
return '<iframe src="http://www.facebook.com/plugins/like.php?href='.$url.'&layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>';
}
?>
<h1>Hey do you like this page PHPacademy?</h1>
<?=facebook_like();?>
ليست هناك تعليقات:
إرسال تعليق