Question

I am building an application that will require users to login via Facebook OR their own email address. I have always in the past used the IonAuth2 library but I cannot quite see how to integrate this with Facebook using the documentation.

Can anyone provide any advice on this matter, would I be better of using another Codeigniter library or does anyone know of how to integrate Facebook into IonAuth2 easily.

I have already got the basics working with Facebook in terms of setting up an application and using the API to login via your Facebook as illustrated below - I am just trying to think of the best way of doing this in relation to the authentication system (ideally ionAuth2 if possible)

    public function index()
    {
      $user = $this->facebook->getUser();

      if($user) {
        try {
            $user_info = $this->facebook->api('/me');
            echo '<pre>'.htmlspecialchars(print_r($user_info, true)).'</pre>';
            echo 'user found';
            // save this info..
            $this->load->model('fb_users_model');
            $this->fb_users_model->insert_user($user_info); // id, first_name, last_name, link, username, gender, email, timezone, locale, verified, updated_time

            echo 'we have logged in..got to some page..';
            echo "<a href=/logout>Logout</a>";
        } catch(FacebookApiException $e) {
            echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
            $user = null;
        }
    } else {
        echo "<a href=\"{$this->facebook->getLoginUrl()}\">Login using Facebook</a>";
    }
}
Was it helpful?

Solution

http://benedmunds.com/ion_auth/

Search the page for facebook, there looks to be a snippet which does what you requested...

EDIT:

There's also a git: https://github.com/dgeorgiev/facebook-ion-auth

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top