Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook require_login not working

I am having some trouble with my little facebook application, I keep getting this friggin error, "Fatal error: Call to undefined method Facebook::require_login()", now the funny bit is that my exact same code is working for other people, but not for me, here is the code.

<?php
require_once( "facebook-php-sdk/src/facebook.php" );
$api_key = "my_api_key";
$secret = "my_secret_key";

$facebook = new Facebook( $api_key, $secret );
$user_id = $facebook->require_login();

echo "Hello World";
echo "Current logged in as <fb:name uid=\"$user_id\" />";
?>

As you can see it is a simple hello USER application, but for some reason this REFUSES to work for me, so if anyone can help out that would be great, thanx in advance!

like image 738
Odyss3us Avatar asked Jun 08 '10 18:06

Odyss3us


1 Answers

Are you using the newest version of the PHP sdk?

Facebook::require_login() is a method from the old SDK.

The new SDK (published in conjunction with the Graph API) is not backwards compatible.

The notion of requiring a login doesn't even exist anymore - you just obtain the user's ID as such.

$user_id = $facebook->getUser();
like image 82
Peter Bailey Avatar answered Nov 05 '22 21:11

Peter Bailey