CodeIgniter Forums
Facebook Ignited Infinite Loop Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Facebook Ignited Infinite Loop Problem (/showthread.php?tid=42863)

Pages: 1 2 3


Facebook Ignited Infinite Loop Problem - El Forum - 06-22-2011

[eluser]programmieraffe[/eluser]
Hey Codeigniter-Folks,

I have a problem using the facebook-ignited package.

Webserver:
MAMP + OSX 10.6.7 / PHP: 5.2.13
( access via "local domain" [etc/hosts - local.mydomain.de, virtual host in MAMP/apache] )

Codeigniter Reactor: 2.0.2
CIBonfire: 1.0.1
Facebook-Ignited: 1.0.4


config/fb_ignited.php:
Code:
config/fb_ignited.php
$config['fb_appid']        = 'XXXXXX6';
$config['fb_secret']    = 'XXXXXX';
$config['fb_cookie']    = true;
$config['fb_canvas']    = '';
$config['fb_auth']        = '';

controller:
Code:
class welcomeFacebook extends Front_Controller{

function getMe(){
                
        // The fb_ignited library is already auto-loaded so call the user and app.
                $this->load->library('fb_ignited');
        $this->fb_me = $this->fb_ignited->fb_get_me(false);    
            
        if (isset($this->request_result))
        {
            $content_data['error'] = $this->request_result;
        }
        $content_data['me'] = $this->fb_me;
        $content_data['fb_app'] = $this->fb_app;
        $this->load->view('welcome_message_fbignited', $content_data); // the default facebook_ignited view template
            
        }
}

The result is an infinite Loop with Chrome and Safari, both when logged in at facebook already or not...

Code:
oauth (www.facebook/com/dialog) 302 Found
uiserver.php (www.facebook.com/connect) 302 Found
/welcomeFacebook/getMe/?code=[….]&state;=[….]
oauth (www.facebook/com/dialog) 302 Found
...

fb_get_me() (Fb_ignited) fails permanently, because $this->CI->facebook->getUser() does not return a user, so it redirects over and over again. I figured out, that there is no signed request. And that getUserFromAvailableData() (base_facebook.php) fails to get user data.

The app-id and app_secret are fine, because i tested it with the javascript-sdk and it all worked well.

How can i debug this? Is there a debug option for php-sdk / facebook-ignited?
Or is it a codeigniter-cookie/session related problem? (Or is it something else? Wink)

Thanks in advance for your help!
Matthias


Facebook Ignited Infinite Loop Problem - El Forum - 06-22-2011

[eluser]alphabase[/eluser]
Having exactly the same issue, have seen your reply at Bitbucket.
Looks like CI doesn't allow the query string, which is returned to by Facebook.
But I've tried several options in the CI-config file, but no success.

Alfonso (Facebook-Ignited) is planning a new release, but I guess this one should be working, too.

Any suggestions?


Facebook Ignited Infinite Loop Problem - El Forum - 06-22-2011

[eluser]programmieraffe[/eluser]
Okay, I have one working solution:

I had a htaccess file, to remove the index.php from the URI. (See below)

If I remove this htaccess file and change the config.php to the following, it works:
Code:
$config['uri_protocol']    = 'AUTO';
$config['index_page'] = 'index.php';

htaccess file used before:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>



But it would be nice if someone could help me out, that i can use clean urls (domain.com/controller/method), because i don't like this way: domain.com/index.php/controller/method.



Facebook Ignited Infinite Loop Problem - El Forum - 06-22-2011

[eluser]osci[/eluser]
in your config
Code:
$config['index_page'] = '';



Facebook Ignited Infinite Loop Problem - El Forum - 06-22-2011

[eluser]alphabase[/eluser]
But then you need htaccess to rewrite those url's, right? And how?


Facebook Ignited Infinite Loop Problem - El Forum - 06-23-2011

[eluser]programmieraffe[/eluser]
I think the problem is the following:

The facebook-api redirects to "domain.com/welcomeFacebook/?code=878908098&state=98989898". Without clean urls, the "?" is the first and is recognized properly. With clean urls and the rewrite rule (see below), there are two "?"-signs in the URI and so only the first one is recognized as parameter. ("domain.com/index.php?/welcomeFacebook/?code=dsflsadkflks&state=98790898")

Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

I don't have a easy solution right now to make this work, maybe the regular expression should be altered to check for "?" in the url?


Facebook Ignited Infinite Loop Problem - El Forum - 06-23-2011

[eluser]toopay[/eluser]
Change your htaccess to
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

and your config.php, look at
Code:
//$config['uri_protocol'] = 'AUTO';
$config['uri_protocol']    = 'PATH_INFO';



Facebook Ignited Infinite Loop Problem - El Forum - 06-23-2011

[eluser]programmieraffe[/eluser]
Yeah, I've tried that, but "/" gives an Internal Server Error, because slashes are for directories.

But I have 2 solutions now:

config.php - enable query strings
Code:
| Please note that some of the helpers won't work as expected when
| this feature is enabled, since CodeIgniter is designed primarily to
| use segment based URLs.

$config['enable_query_strings'] = TRUE;

Or if you don't want to enable it global, paste this to your constructor or method:
Code:
parse_str($_SERVER['QUERY_STRING'],$getArr);
                $_REQUEST['state']=$getArr['state'];
                $_REQUEST['code']=$getArr['code'];

I do not know if this causes some security issues...


Facebook Ignited Infinite Loop Problem - El Forum - 06-23-2011

[eluser]toopay[/eluser]
Did you try change uri protocol to 'PATH_INFO' in your config? Sometime you need that to get the "$_GET" param properly. No need to use query string, it will give you more troubles.


Facebook Ignited Infinite Loop Problem - El Forum - 06-23-2011

[eluser]programmieraffe[/eluser]
I've tried to use 'PATH_INFO', but this does not work for me. Will it really cause more trouble? Because i'm still using path segments for my url instead of ?c=controller.