PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Viet Vu   Facebook Plugin   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: Sample
Class: Facebook Plugin
Insert Facebook social plugins in Web pages
Author: By
Last change:
Date: 12 years ago
Size: 883 bytes
 

Contents

Class file image Download
<?php
require 'facebook.php' ;

function
_getCurrentUrl () {
   
$protocol = strpos ( strtolower ( $_SERVER['SERVER_PROTOCOL'] ) , 'https' ) === FALSE ? 'http' : 'https' ;
   
$host = $_SERVER['HTTP_HOST'] ;
   
$script = $_SERVER['SCRIPT_NAME'] ;
   
$params = $_SERVER['QUERY_STRING'] ;
    if (
$params != '' ) {
        return
$protocol . '://' . $host . $script . '?' . $params ;
    }else
        return
$protocol . '://' . $host . $script ;
}

$facebook = JxFacebook::getInstance ( _getCurrentUrl () ) ;
$facebook->setOpenGraph ( 'url' , $facebook->getUrl () ) ;
$facebook->setType ( 'blog' ) ;
?>
<html <?php echo $facebook->getHtml () ; ?>>
    <head>
        <?php echo $facebook->getHead () ; ?>
</head>
    <body>
        <?php echo $facebook->getScript () ; ?>
<?php echo $facebook->getPlugin ( 'comments' ) ; ?>
</body>
</html>