Wednesday, February 27, 2013

Facebook Graph Api Example Script by Php

All the Facebook Graph Api Example Code using php.This bundle of script contain below facebook script .
  • Facebook  Activity Feed
  • Facebook Add Friends
  • Facebook Comments
  • Facebook Like Button
  • Facebook Like Box
  • Facepile
  • Facebook Recommendation
  • Facebook Status update
  • Live Stream
Download Facebook Script
Facebook Activity Feed
Facebook Add Friends
Facebook Comments
Facebook Like Button
Facebook Like Box
Facepile
Facebook Recommendation
Facebook Status update
Live Stream

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;
    ?> 


 

Facebook Activity Feed Using Php

Facebook Activity Feed plugin shows users what their friends are doing on your site through likes and comments.

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
get_activity_feed() and apply its parameter.

class Facebook_plugins_class
{
    var $app_id = '115461585200271';
    var $lang = 'en_US'; //en_US, fr_FR, es_LA, ko_KR, ja_JP, de_DE
    var $fb_sdk = '1';
   
    function Facebook_plugins_class($criteria=array()) {
        static $witness;
        if($criteria['app_id']!='') $this->app_id = $criteria['app_id'];
        if($criteria['lang']!='') $this->lang = $criteria['lang'];
        if($criteria['fb_sdk']!='') $this->fb_sdk = $criteria['fb_sdk'];
       
        if($witness=='') {
            if($this->fb_sdk=='1') echo '<div id="fb-root"></div><script src="http://connect.facebook.net/'.$this->lang.'/all.js#appId='.$this->app_id.'&amp;xfbml=1"></script>';
            $witness=1;
        }
    }

function get_activity_feed($criteria=array()) {
        $domain = $criteria['domain'];
        $width = $criteria['width'];
        $height = $criteria['height'];
        $colorscheme = $criteria['colorscheme'];
        $header = $criteria['header'];
        $recommendations = $criteria['recommendations'];
        $border_color = $criteria['border_color'];
        $font = $criteria['font'];
       
        if($domain=='') $domain = '';
        if($width=='') $width = '300';
        if($height=='') $height = '300';
        if($colorscheme=='') $colorscheme = 'light'; //light, dark
        if($header=='') $header = 'true';
        if($recommendations=='') $recommendations = 'false';
        if($border_color=='') $border_color = '';
        if($font=='') $font = ''; //'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'
       
        $content = '<iframe src="http://www.facebook.com/plugins/activity.php?site='.$domain.'&amp;width='.$width.'&amp;height='.$height.'&amp;header='.$header.'&amp;colorscheme='.$colorscheme.'&amp;font='.$font.'&amp;border_color='.$border_color.'&amp;recommendations='.$recommendations.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'px; height:'.$height.'px;" allowTransparency="true"></iframe>';
       
        return $content;
    }



2) call this function activity file ( activity.php )

<?php
include_once('Facebook_plugins_class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PhpWeb Blog</title>
</head>
<body>
<h3>Facebook Activity Feed</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->get_activity_feed(array('domain'=>'themeforest.net', 'width'=>'460'));
    echo $display;
    ?>
</div>
</body>
</html>


 

Facebook Status Update Using Php Script

Facebook Status Update using Facebook Graph Api and Php Script.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 display_status_update($criteria=array()) {
        $app_id = $criteria['app_id'];
        $title = $criteria['title'];
        $message = $criteria['message'];
        $name = $criteria['name'];
        $link = $criteria['link'];
        $picture = $criteria['picture'];
        $caption = $criteria['caption'];
        $description = $criteria['description'];
       
        if($app_id=='') $app_id = $this->app_id;
        if($title=='') $title = '';
        if($message=='') $message = '';
        if($name=='') $name = '';
        if($link=='') $link = '';
        if($picture=='') $picture = '';
        if($caption=='') $caption = '';
        if($description=='') $description = '';
        $random = rand(9999,9999999).rand(9999,9999999).rand(9999,9999999);     
        $js ='
        <script>
        function fc_post_fb_update_'.$random.'() {
            FB.ui({
                method: \'feed\',
                message: \''.$message.'\',
                name: \''.$name.'\',
                 link: \''.$link.'\',
                 picture: \''.$picture.'\',
                 caption: \''.$caption.'\',
                 description: \''.$description.'\',
            });
        }
        </script>';
        $content = '<a href="javascript:" onclick="fc_post_fb_update_'.$random.'()">'.$title.'</a>';
        return $content.$js;
    }


1) Create Facebook Status Update file :(fb_update.php ) 
in this file include the above class and call this function.

<?php
include_once('Facebook_plugins_class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php Web tutorials</title>
</head>
<body>
<h3>Facebook status update dialog</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status'));
    echo '1. Standard:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br>';
   
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status', 'link'=>'http://tutjunction.com'));
    echo '2. Update status + share an attached link:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br><br>';
   
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status', 'link'=>'http://tutjunction.com', 'description'=>'Have a look on the services offered by this company!', 'picture'=>'http://tutjunction.com/wp-content/upload/'));
    echo '3. Update status + share an attached link + description + custom picture attached:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br><br>';
    echo '<b>Tip:</b><br>Our Facebook status function doesn\'t require your users to authorize your application before they can post to their wall. They can do it right away! Just try it yourself with one of the 3 examples above.';  ?>
</div>
</body>
</html>



Tuesday, February 26, 2013

Create Dynamic Html2PDF by Dompdf Library

dompdf is an HTML to PDF converter. At its heart, dompdf is a compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.Easy PDF generation with PHP.

Features

  • handles most CSS 2.1 and a few CSS3 properties, including @import, @media & @page rules
  • supports most presentational HTML 4.0 attributes
  • supports external stylesheets, either local or through http/ftp (via fopen-wrappers)
  • supports complex tables, including row & column spans, separate & collapsed border models, individual cell styling
  • image support (gif, png (8, 24 and 32 bit with alpha channel), bmp & jpeg)
  • no dependencies on external PDF libraries, thanks to the R&OS PDF class
  • inline PHP support  
Example :

<?php
require_once("dompdf_config.inc.php");
$html =
    '<html><body>'.
    '<p>Hello World!</p>'.
    '</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);

$dompdf->render();
$dompdf->stream("hello_world.pdf");
?>

Click For Demo  Click For Download