The following code should return the email address of the user logged in.
<?php
require_once('facebook-php-sdk/src/facebook.php');
// Create our Application instance (replace this with your appId and secret).
$facebook= new Facebook(array(
'appId' => '2453463636',
'secret' => '365653656565656',
'allowSignedRequest' => false,
));
$user = $facebook->getUser();
print_r($user);
if ($user) {
try {
// Get the user profile data you have permission to view
// $user_profile = $facebook->api('/me');
$user_profile = $facebook->api('/me?fields=picture.width(100).height(100),first_name,last_name,username,email');
echo $user_profile['email'];
} catch (FacebookApiException $e) {
$user = null;
error_log($e);
print_r($e);
}
} else {
die("failed");
}
?>
Instead it returns "failed", and print_r($user) returns 0.
Really don't know what to do.
In the dashboard:
I have set up a website platform to view my app.
The jist:
The "App Domains" = www.app.com
"Site Url" = http://www.app.com/test
The site url is actual the app. I try to access the getUser
in urls such as http://www.app.com/test/fbuser
, where it returns 0 and die clause.
Did I set this up wrong?
EDIT
Curl on my localhost server
also the "Configure Command" is quite different(see below for localhost screen shot)
The remote server info mentions "curl" in this blob of text for Configure Command