Welcome Guest, Not a member yet? Register   Sign In
Facebook Auth
#1

[eluser]Carmichael[/eluser]
Hi, I am having problem with Facebook Auth on my website.

I have facebook.php and facebook_base.php in libraries.

Controller
Quote:<?php
class Auth extends MY_Controller
{

function __construct()
{
parent::__construct();
}

function facebook_auth()
{

$this->view_data['view_title'] = "Facebook Login";

$fb = $this->facebook->getUser();

if ($fb) {
try {
$this->view_data['fb_user'] = $this->facebook->api('/me');
} catch (FacebookApiException $e) {
$fb = null;
}
}

if ($fb) {
$this->view_data['logout_url'] = $this->facebook->getLogoutUrl();
} else {
$this->view_data['login_url'] = $this->facebook->getLoginUrl();
}

}
}
?>

View
Code:
<?php if (@$fb_user): ?>
        <pre>
            &lt;?php echo print_r($fb_user, TRUE) ?&gt;
        </pre>
        <a href="&lt;?php echo $logout_url ?&gt;">Logga ut</a>
    &lt;?php else: ?&gt;
        <h2>Logga in med Facebook</h2>
        <a href="&lt;?php echo $login_url ?&gt;">Logga in</a>
    &lt;?php endif; ?&gt;
    
    &lt;?php echo @$fb_user['first_name']; ?&gt;

The user doesn't get logged in because getUser() returns 0 even when the user hit login.


Messages In This Thread
Facebook Auth - by El Forum - 06-16-2012, 04:48 PM
Facebook Auth - by El Forum - 06-18-2012, 04:01 AM
Facebook Auth - by El Forum - 06-18-2012, 05:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB