I have the following code which works when no facebook session exists
session_start();
# We require the library
require("/var/www/facebook.php");
# Creating the facebook object
$facebook = new Facebook(array(
'appId' => 'app_id',
'secret' => 'secret',
'cookie' => true
));
# check if active session exists
$session = $facebook->getSession();
if(!empty($session)) {
# Do some stuff here
} else {
# There's no active session, go get one
$login_url = $facebook->getLoginUrl();
header("Location: ".$login_url);
}
After logging into facebook, it goes to a facebook screen which says that my app will receive Your basic info. Is it possible to get the email address right from the start too? I know how to get further permissions after logging in successfully. What I am after is to get extended permissions right from the start, most importantly the email.
What do I need to do to the else to get the email along with the basic info?
You need to tell Facebook the scopes you need.