ericbae / XTA2

CodeIgniter Tank Auth with Facebook, Twitter, Google Friend Connect, OpenID
http://xta2.ericbae.com
Other
105 stars 27 forks source link

"cannot find the Facebook user" #7

Open matthewphewes opened 12 years ago

matthewphewes commented 12 years ago

I've got everything setup correctly I think - all of the other services are working... Facebook authorizes and responds with a code but I get the message on my end "cannot find the Facebook user" no matter what I try.

I saw somewhere there were some PHP extensions that needed to be installed - I enabled them and all... Could there be something else I'm doing wrong? Did Facebook change something?

Thanks for any help you can provide!

timmahoney commented 12 years ago

I replaced the Facebook files in the libraries folder with the default Facebook PHP SDK files. Then, I set up a /application/config/facebook.php file and put my application information in here like so:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config["appId"] = "APP ID";
$config["secret"] = "APP SECRET";
$config["fileUpload"] = false; // or true whatever you like.

/* End of file facebook.php */
/* Location: ./application/config/facebook.php */

Config files for libraries that get auto-loaded can load config file information from files named after the library - hence facebook.php.

The issue is that it's not loading the cookie correctly. I'm not sure what version of the Facebook SDK he's got in here, but this worked perfectly.

timmahoney commented 12 years ago

Forked and updated here: https://github.com/timmahoney/XTA2

matthewphewes commented 12 years ago

Awesome - thanks!

jaspalSingh commented 12 years ago

@timmahoney ,

There is a problem in the code.

  1. Add $this->config->load('facebook'); in the constructor of the auth controller OR put $autoload['config'] = array('facebook'); in the autoload.php file.
  2. In the file application\views\auth\login_form.php file instead of <?php echo $this->config->item('appId');?> you have used <?php echo $this->config->item('facebook_app_id');?> this is causing errors.

Cheers Jaspal Singh

cyberjunkie commented 12 years ago

@timmahoney thanks for forked update! For some reason it returns the same user when i log into different facebook accounts. Is anyone else having this issue? I'm also getting Call to undefined method Facebook::get_facebook_cookie()

timmahoney commented 12 years ago

Hi @cyberjunkie - I personally haven't run into this, but I'll check it out later tonight and try to replicate it.

cyberjunkie commented 12 years ago

@timmahoney thank you! I'll be searching for solutions as well

cyberjunkie commented 12 years ago

@timmahoney I looked in the files and saw that welcome.php view where it goes after logging in uses the get_facebook_cookie() function from the non PHP SDK file. And as mentioned, echo $username returns the same user for all facebook logins. Not sure how to fix it. I think the facebook.php controller should be capitalized.

cyberjunkie commented 12 years ago

Has anyone got the plugin to work? I'm logging in with different Facebook accounts and it uses the same Facebook user from the db. I looked at the code, tracing how everything works but can't spot where the error is..

grey04 commented 12 years ago

I think I have found the problem. In controllers/auth_other.php there is $fb_user = $this->facebook->getUser(); $this->session->set_userdata('facebook_id', $fb_user['id']); $user = $this->user_model->get_user_by_sm(array('facebook_id' => $fb_user['id']), 'facebook_id');

But the new getUser doesn't return an array, just the id Changing to this should fix it $this->session->set_userdata('facebook_id', $fb_user); $user = $this->user_model->get_user_by_sm(array('facebook_id' => $fb_user), 'facebook_id');

timmahoney commented 12 years ago

I'll check it out, thanks @grey04 !

itskawsar commented 11 years ago

@grey04 : The problem still remain here! Please check http://tormuz.com/ci_oauth/index.php/auth_other/

ivailoiliev commented 11 years ago

has anyone got this script working ?

ulac commented 10 years ago

Any solution or an upgrade for this? Still getting cannot find the Facebook user.

alokbanjare commented 10 years ago

To imcl and everyone else having this xta2 and facebook issue, I found the solution on this url: http://blog.codebusters.pl/en/entry/oauth-20-facebook-changes-and-cookie-problem-in-codeigniter.

Basically you have to edit get_facebook_cookie() function inside facebook library, and in the welcome view change $fb_cookie[‘session_key’] to $fb_cookie[‘code’].

Hope it helps.