We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Facebook PHP SDK in Expressionengine getSessionFromRedirect returning NULL

Development and Programming

Dan CRYSTAL's avatar
Dan CRYSTAL
4 posts
11 years ago
Dan CRYSTAL's avatar Dan CRYSTAL

I am trying to upgrade an existing Facebook Login within an Expressionengine based site from API v1.0 to v2.2 as per the FB platform upgrade requirements. As the Javascript SDK is not an option (due to integration with the EE members module) I have opted to use the PHP SDK v4.

I have a working Login URL but when the user returns from the Facebook login URL, after signing in, getSessionFromRedirect() returns NULL, instead of a session.

I have scoured the internet and reviewed the answers posted for people with similar problems but none of the solutions have worked:

  • adding ‘/’ to the end of OAuth redirect URI
  • splitting the code into two different classes / files to avoid getLoginUrl() changing the state
  • and various other ‘trial and error’ hacks
  • I am currently using an adaptation of Ben Marshals Codeigniter example which unfortunately still returns NULL when the user is redirected back.

The function to generate the FB login URL looks similar to this:

public function generate_fb_url(){
    $tags = $this->EE->TMPL->tagdata;
    $vars = array();
    $redirect='http://redirect.com/?ACT=123';
    $config=array('redirect'=>$redirect);

    $this->EE->load->library('facebook_lib', $config, 'facebook');
    array_push($vars, array('status'=>'true', 'error'=>'', 'fburl'=>$this->EE->facebook->login_url(), 'debug'=>'redirect -'.$redirect));
    return $this->EE->TMPL->parse_variables($tags, $vars);
}

It simply initiates the CI Facebook library and creates the FB URI. As soon as the user is returned from Facebook the application dies and doing a var_dump($this->session); returns NULL.

Any input would be greatly appreciated, I’m tearing my hair out at the moment! I have a horrible feeling that the problem is related to Expressionengine’s handling of sessions but I could be wrong.

       
Scotta's avatar
Scotta
136 posts
7 years ago
Scotta's avatar Scotta

It’s been years since you posted that topic but Facebook Login seems to be still an issue with EE. Did you get something working ?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.