Wednesday, February 27, 2013

Facebook Like Button Using Php Script

Facebook Like button lets users share pages from your site back to their Facebook profile with one click.
Its easy and very simple.But First You have Create Facebook Application because without any application ID this Task is not done.

Step for Facebook Update State :

1) Create Facebook class file :( Facebook_plugins_class.php ) 

in this add application id and language code and set facebook sdk on and then create one function
display_status_update() and apply its parameter.

function get_like_box($criteria=array()) {
        $url = $criteria['url'];
        $width = $criteria['width'];
        $height = $criteria['height'];
        $colorscheme = $criteria['colorscheme'];
        $header = $criteria['header'];
        $showfaces = $criteria['showfaces'];
        $stream = $criteria['stream'];
       
        if($url=='') $url = '';
        if($width=='') $width = '292';
        if($height=='') $height = '427';
        if($colorscheme=='') $colorscheme = 'light'; //light, dark
        if($header=='') $header = 'true';
        if($show_faces=='') $show_faces = 'true';
        if($stream=='') $stream = 'true';
       
        $content = '<iframe src="http://www.facebook.com/plugins/likebox.php?href='.$url.'&amp;width='.$width.'&amp;colorscheme='.$colorscheme.'&amp;show_faces='.$show_faces.'&amp;stream='.$stream.'&amp;header='.$header.'&amp;height='.$height.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'px; height:'.$height.'px;" allowTransparency="true"></iframe>';
       
        return $content;
    }


2) Create Facebook like file :(fb_like.php )

<?php
    include_once('Facebook_plugins_class.php');

    $f1 = new Facebook_plugins_class();
    $display = $f1->get_like_button(array('url'=>'https://www.facebook.com/profile.php?id=100001462485647'));
    echo '<div style="padding-bottom:8px;">Available on tutjunction: <a href="https://www.facebook.com/profile.php?id=100001462485647" target="_blank">Facebook WPress Viral tool for WordPress</a></div>';
    echo ''.$display.'<br><br>';
    ?>
</div>
<h3>Facebook Like box</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->get_like_box(array('url'=>'https://www.facebook.com/pages/Hellomeed/195450280529871'));
    echo $display;
    ?> 


 

No comments:

Post a Comment

Thanks....