facebook SDK [SOLVED] take a peek if you have trouble!

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

facebook SDK [SOLVED] take a peek if you have trouble!

Post by Torniquet »

This thing is really starting to grate my goat now!

I click the 'logout' button, yet i remain logged into my site via facebook...

I am using the php SDK, code to follow.

Can somone tell me how to work this bloody thing! :)

index

Code: Select all

<?php
require_once("core/init.php");
require_once("core/function.php");

/*if($session) {
	header("Location: signup.php");
	exit;
}*/

?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home page</title>
<link href='http://fonts.googleapis.com/css?family=Macondo' rel='stylesheet' type='text/css'>
<link href='/style/main.css' rel='stylesheet' type='text/css'>
</head>

<body>
<?=$logUrl?>
<div id="wrapper">
	<h1>Blood Hunt</h1>
    <div>
    	<a href="<?=$loginUrl?>" id="fb-login"></a>
    </div>
    <div>
    	<p>Blood Hunt is in pre Alpha.</p>
        <p>Use your Facebook account to login. All information accessed by Blood Hunt is kept private and is not stored in our system.</p>
    </div>
</div>
</body>
</html>
facebook crap

Code: Select all

require_once($_SERVER['DOCUMENT_ROOT'] . "/libs/facebook.php");
$facebook_config = array(
	"appId"		=>	"*********************",
	"secret"	=>	"*********************"
);

$facebook = new Facebook($facebook_config);

$session = $facebook->getUser();
$me = null;

if($session)
{
	try
	{
		$me = (object)$facebook->api('/me');
	}
	catch (FacebookApiException $e)
	{
		echo $e;
		$me = null;
	}
}

if($me)
{
	$login_options = array("next" 	=> "http://www.blood-hunt.tapt-in.net/logout.php");
	$logoutUrl = $facebook->getLogoutUrl($login_options);
	$logUrl = "<a href='$logoutUrl'>Log out</a>";
}
else
{
	$login_options = array(
		"redirect_uri" 	=> "http://www.blood-hunt.tapt-in.net",
		"scope"			=>	"email,read_stream,publish_stream,user_photos,read_mailbox,offline_access"
	);
	$loginUrl = $facebook->getLoginUrl($login_options);
	$logUrl = "<a href='$loginUrl'>Log in</a>";
}
logout

Code: Select all

<?php
require_once("core/init.php");
unset($_SESSION);
unset($_COOKIE);
?>
ta xxx
Last edited by Torniquet on Wed Feb 08, 2012 6:42 pm, edited 1 time in total.
New Site Coming Soon! Stay tuned :D
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: facebook SDK

Post by Chris »

I'm guessing it sends an encryption key and a password to Facebook, then lets you make access to the API server. Couldn't be that difficult to figure out. What is in $me? print_r($me).
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: facebook SDK

Post by Torniquet »

$me contains all of my facebook information returned by the API. Username, name, email, etc etc

You woulda thought it wouldnt be that hard to use it, but it is a sodding pain in the ass!
New Site Coming Soon! Stay tuned :D
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: facebook SDK

Post by Torniquet »

I appear to fixed the effin thing :D

new logout.php

Code: Select all

<?php
require_once("core/init.php");
unset($_SESSION);
setcookie("PHPSESSID", "", time() - 1000);
header("Location: index.php");
?>
New Site Coming Soon! Stay tuned :D
Post Reply

Return to “Coding”