pengkong / A3M-for-CodeIgniter-2.0

A3M Peanutbutter - For CodeIgniter 2.0
Other
110 stars 84 forks source link

Facebook connect don't work anymore ? #14

Closed mmind-hub closed 11 years ago

mmind-hub commented 11 years ago

Since yesterday my websites using correctly this project dosen't work anymore with the facebook connect, i have a white page when the users try to connect. Is it a temporary bug from facebook ?

donjakobo commented 11 years ago

Going to investigate, I'm actually noticing this on my production site today, it may be a FB change that is not impacting the service. Please investigate by yourself too and post an update.

What is happening from my end, I get the challenge to login from FB, then the redirect doesn't work from FB, just get a blank page with the URL &next= my site url.

Found a reference to this issue, might be just facebook only, here is a ticket: https://developers.facebook.com/bugs/361998213890295

As this is a known issue as of yesterday I have placed an update on the ticket, I would suggest you do the same, this is not looking as a code issue (possibly a legacy code issue? not sure yet).

pengkong commented 11 years ago

1) drop in facebook_lib.php config file into the config folder 2) drop the Facebook_lib.php library file into the library folder 3) download the latest fb library from https://github.com/facebook/facebook-php-sdk and put it "as-it-is-without-modification" into the third party folder (that path should be require_once(APPPATH.'third_party/facebook/src/facebook.php'); 4) study what im doing in connect_facebook.php controller

this works for sure, so maybe it can give you all a head start

On Sat, Oct 27, 2012 at 2:33 AM, Jakub notifications@github.com wrote:

Going to investigate, I'm actually noticing this on my production site today, it may be a FB change that is not impacting the service. Please investigate by yourself too and post an update.

What is happening from my end, I get the challenge to login from FB, then the redirect doesn't work from FB, just get a blank page with the URL &next= my site url.

— Reply to this email directly or view it on GitHubhttps://github.com/pengkong/A3M-for-CodeIgniter-2.0/issues/14#issuecomment-9822633.

Best Regards, PK

pengkong commented 11 years ago

use this for fb sdk

https://github.com/facebook/facebook-php-sdk

On Sat, Oct 27, 2012 at 10:25 AM, PK pengkong@gmail.com wrote:

1) drop in facebooklib.php config file into the config folder 2) drop the Facebook

1) drop in facebook_lib.php config file into the config folder 2) drop the Facebook_lib.php library file into the library folder 3) download the latest fb library from https://github.com/facebook/php-sdkand put it "as-it-is-without-modification" into the third party folder (that path should be require_once(APPPATH. 'third_party/facebook/src/facebook.php'); 4) study what im doing in connect_facebook.php controller

this works for sure, so maybe it can give you all a head start

On Sat, Oct 27, 2012 at 2:33 AM, Jakub notifications@github.com wrote:

Going to investigate, I'm actually noticing this on my production site today, it may be a FB change that is not impacting the service. Please investigate by yourself too and post an update.

What is happening from my end, I get the challenge to login from FB, then the redirect doesn't work from FB, just get a blank page with the URL &next= my site url.

— Reply to this email directly or view it on GitHubhttps://github.com/pengkong/A3M-for-CodeIgniter-2.0/issues/14#issuecomment-9822633.

Best Regards, PK

Best Regards, PK

donjakobo commented 11 years ago

BTW, Facebook's response, they disabled the legacy OAuth system, need to update the code. Hence this stopped working the other day.

https://developers.facebook.com/bugs/506823259335622

donjakobo commented 11 years ago

I've been working this all morning, even with updated FB SDK 3.2.0 I get a redirect look as I've traced it into /account/connect_facebook.php

Keeps redirecting... I'm about to pull out hair, @pengkong you try this in real world or just theory?

pengkong commented 11 years ago

that's my real world code.

see: www.vanitytrove.com/sg

pengkong commented 11 years ago

redirect loop is likely caused by the settings at the fb dev page.

ensure those are correctly set

On Sun, Oct 28, 2012 at 12:38 PM, PK pengkong@gmail.com wrote:

that's my

On Sun, Oct 28, 2012 at 12:38 PM, PK pengkong@gmail.com wrote:

that's why real world code.

see: www.vanitytrove.com/sg

On Sun, Oct 28, 2012 at 2:45 AM, Jakub notifications@github.com wrote:

I've been working this all morning, even with updated FB SDK 3.2.0 I get a redirect look as I've traced it into /account/connect_facebook.php

Keeps redirecting... I'm about to pull out hair, @pengkonghttps://github.com/pengkongyou try this in real world or just theory?

— Reply to this email directly or view it on GitHubhttps://github.com/pengkong/A3M-for-CodeIgniter-2.0/issues/14#issuecomment-9838430.

Best Regards, PK

Best Regards, PK

Best Regards, PK

donjakobo commented 11 years ago

I've got it working again, used a combination of PHP-SDK & JS (as per a FB example). The issue was a constant redirect as CI would generate a redirect() incorrectly.

I dunno WHAT the issue was for me, but adding the JS component as a redirect allowed for a perfect login without a redirect loop. Will show my code in my own repo for review.

dabilax commented 11 years ago

Hi donjakobo. I too have been experiencing the redirect loop issue when trying to authenticate with fB. After also pulling my hair out trying to resolve the issue, I stumbled across this page. Was glad to see that this is a recent problem (as I had it working ok a month or so ago). However, after downloading your source from your repo, and reconfiguring accordingly (with my fB app_id and secret), I am still experiencing the redirect! Are you able to suggest what might be the issue???

donjakobo commented 11 years ago

@dabilax I got a solution actually, have been too busy to update, I will work on that in a few minutes :) I ended up using a combination of JS & the PHP-SDK (from FB).

The redirect I did using the JS, which captures the needed variables. Works for me, otherwise I didn't find a 'cleaner' fix for it. Stand-by for an update in my repo (test it and I can merge it as a 'right now' fix) until someone else gets something cleaner.

controllers/account/connect_facebook.php (this fragment replaces the redirect() fn in the bottom of the controller)

    // Redirect to login url if not logged in using fb-js
?>
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <body>
    <?php if (!$this->facebook_lib->user) { ?>
      <fb:login-button></fb:login-button>
    <?php } ?>
    <div id="fb-root"></div>
    <script>               
      window.fbAsyncInit = function() {
        FB.init({
          appId: '<?php echo $this->facebook_lib->fb->getAppID() ?>', 
          cookie: true, 
          xfbml: true,
          oauth: true
        });
        FB.Event.subscribe('auth.login', function(response) {
          window.location.reload();
        });
        FB.Event.subscribe('auth.logout', function(response) {
          window.location.reload();
        });
      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>
  </body>
</html>
<?php       
dabilax commented 11 years ago

Great! Works fine for the time being. Thanks for the quick reply @donjakobo

donjakobo commented 11 years ago

You tested it already on your end? Working out for you as well? Or just waiting on my commit..?

dabilax commented 11 years ago

Yep. Tested and working! :-) Did as you suggested and replaced the redirect function in the bottom of the connect_facebook controller.

donjakobo commented 11 years ago

I have committed all code changes to this primary repo. Feel free to grab the code and test, if there are issues, let me know.

dabilax commented 11 years ago

Thanks @donjakobo. Now to move on to my next goal and make it all ajax enabled :)

errorstudent commented 11 years ago

sorry, where the function destroySession ?

my error like this : ( ! ) Fatal error: Call to undefined method Facebook::destroySession() in application/modules/account/helpers/facebook_helper.php on line 1259

confact commented 11 years ago

I have pulled the new code and test it and it works fine. Thanks.

donjakobo commented 11 years ago

@errorstudent can you try to correct/offer more info on the error about when you got it (on logout?) I updated the underlying CI to 2.1.3 which had a session security patch (not sure if related)

donjakobo commented 11 years ago

@confact thank for the test :+1:

confact commented 11 years ago

Now when i tested again i got the same error as @errorstudent, I added the destroySession function from the official facebook php sdk facebook_base php file in the facebook_helper and it worked again.

donjakobo commented 11 years ago

Alright.. I've updated the facebook_helper.php to include the destroySession() fn. All should be set on this issue.

errorstudent commented 11 years ago

wow, thanks @donjakobo, works fine :+1:

SamoSlaus commented 11 years ago

Well there's something wrong with facebook_helper.php . The code is double and after removig double code i traced error to this $metadata = $this->getMetadataCookie();

after renaming getMetadataCookie() to getMetadataCookieName() I get this error:

Message: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object

donjakobo commented 11 years ago

@SamoSlaus, please open a new issue for this.