Login with Facebook On your Site

Now you download your facebook sdk .

 

1)unzip the facebook           sdk folder to /www/newfolder

2)open editor

3)Now type this simple program

 

<?php

include(“src/facebook.php”);

$h=new Facebook(

array(‘appId’=>’you app id’,’secret’=>’your secret id’,’cookie’=>true);

);

$h=$facebook->getUser();

$me=null;

if($h)

{

try{

$me=$facebook->api(‘/me’);

}

catch(FacebookApiException $e){

echo $e->getMessage();

}

}

if($me)

{

$logoutUrl=$facebook->getLogoutUrl();

echo “<a href=$logoutUrl>Logout</a>”;

}else

{

$loginUrl=$facebook->getLooginUrl(array(‘scope’=>’publish_stream’));

echo “<a href=$loginUrl>Login</a>”;

}

?>

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s