0

I am using Facebook API for login with Facebook on my codeigniter app. It seems to be working fine except when the user is already logged in to Facebook but has never authorized my app. I redirect him to getLoginUrl() which should take him to authorize my app, but it never happens!

I am really lost and have been looking for solutions all around, any help would be appreciated

Here is my index function that is called on facebook login click:

 $data=array( 'redirect_uri' => '/facebookcontroller/handle_facebook_login/', 'scope' => 'publish_stream,email' ); redirect($this->fbconnect->getLoginUrl($data)); 

And my redirect_uri is valid, I double checked.

So If the user is logged in, It will attempt to redirect him to getloginurl() which should take the user to authorize, but it doesn't. It goes straight to the redirect_uri.

2
  • 1
    check this one out. Else what are you tried? Post some code for us :) Commented Dec 7, 2012 at 11:36
  • okay I posted my contoller's index method Commented Dec 7, 2012 at 11:41

1 Answer 1

1

Do you check on user?

 // Init the Facebook SDK $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'cookie' => true )); // Get the current user $user = $facebook->getUser(); if (!$user) { $loginUrl = $facebook->getLoginUrl(array( 'scope' => $scope, 'redirect_uri' => $app_url, )); echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>"; } else{ $user_profile = $facebook->api('/me'); // STUFF } 
Sign up to request clarification or add additional context in comments.

11 Comments

I am testing on my facebook account, I have previously authorized it, but erased all my facebook info from my database. I tried requesting the user info and it threw that error: Invalid or no certificate authority found, using bundled information It is worth mentioning that when it returns from facebook, it brings 2 variables: state, and code. Maybe I need to do further processing on it?
Okay. Maybe I think I know what is wrong. You have already AUTH your own account to the APP. You need to un-AUTH it. go under your facebook settings, and delete the app auth
facebook will give you an access token and set it automatically. After you have redirected, you should be able to gain access to the $facebook->api('/me'); Stuff like: echo "id: " . $user['id']; or $access_token = $facebook->getAccessToken();
Try clearing cookie and start over with auth and stuff. Else Try do what he did in other question
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.