I can't seem to make the email permission required.
If a user unticks the email udring the FB login, my code breaks down. And when I try writing code around this problem (try to alert the user to accept the email permission requisite.), it won't work; the user would have to revoke the App's access manually in their FB settings, and that is obviously out of the question.
So how can I make the email permission required as part of my app/website?
Tbh, I couldn't read through the entire Facebook API docs without scratching my head through it.
Here is what I have currently:
var $user = null;
function __construct()
{
//blahblahlblah
//blahblahblah (Code needed for facebook login to work)
$this->user = $this->facebook->getUser();
if ($this->user)
{
try
{
// Proceed knowing you have a logged in user
$this->user = $this->facebook->api('/me');
$this->logoutUrl = $this->facebook->getLogoutUrl( array('next' => base_url() . 'connect/logout') );
}
catch (FacebookApiException $e)
{
error_log($e);
$this->user = null;
}
}
}
function process()
{
// If the Facebook user allows his/her email to be shared.
// [If they don't, skip to the `else` statement below]
if (isset($this->user['email']))
{
//Great! I can process normally
}
// If the Facebook user doesn't share their email.
else
{
//What do I do here?
//I'm not sure how the OAuth works, so that's why im checking
echo 'email is required. line 86 , connect.php controller';
}
}