Part of the EllisLab Network
   
2 of 3
2
Facebook Connect with codeignitor
Posted: 29 March 2010 11:36 AM   [ Ignore ]   [ # 16 ]  
Summer Student
Total Posts:  30
Joined  05-11-2008

Hmm. Getting this error now:

Fatal errorCall to undefined method Facebook::clear_cookie_state() 
Profile
 
 
Posted: 29 March 2010 11:41 AM   [ Ignore ]   [ # 17 ]  
Grad Student
Rank
Total Posts:  83
Joined  04-07-2009

Oh ya you should install the latest facebook library too, sorry like I said it’s been a while. Just download the facebook files from the facebook dev site and replace those with the files in your app.

Profile
 
 
Posted: 29 March 2010 12:01 PM   [ Ignore ]   [ # 18 ]  
Summer Student
Total Posts:  30
Joined  05-11-2008

Ah of course, hence the missing function. Done and testing now. Many thanks!

Profile
 
 
Posted: 30 March 2010 02:38 PM   [ Ignore ]   [ # 19 ]  
Summer Student
Total Posts:  1
Joined  03-30-2010

Hey guys, thanks for posting all of this. I’ve been struggling with this issue for awhile. Deadly, can you confirm that worked for you? I am putting that code in now, but testing it is difficult because I have to wait for the sessions to expire in order to recreate the white screen.

Thanks again.

Profile
 
 
Posted: 31 March 2010 12:45 AM   [ Ignore ]   [ # 20 ]  
Summer Student
Total Posts:  10
Joined  02-26-2010

Wow, this is beautiful. I’ve had this problem for quite some time as I wrote on my blog.

I dropped in the edited library along with the new facebook client library and it simply works.

I can confirm this work because my session was already expired and all I got was the blank page.

Great job guys!

Profile
 
 
Posted: 01 April 2010 11:33 AM   [ Ignore ]   [ # 21 ]  
Summer Student
Total Posts:  30
Joined  05-11-2008

It’s much better for me as well, with one issue remaining after a session expires:

SeverityNotice

Message
Uninitialized string offset0

Filename
libraries/Facebook_connect.php

Line Number
82 

Edit: line 82 is the last line here:

$profile_data     = array('uid','first_name''last_name''name''locale''pic_square''profile_url');
$info $this->fb->api_client->users_getInfo($this->user_id$profile_data);
$user $info[0]

Oddly, this only seems to happen in Firefox, not Safari?

Edit 2:
Think I may have it sussed now. Will check in tomorrow.

Edit 3: Yep, only happens in Firefox, the first I time I hit the site after my session expires. A reload of the page and everything is fine. Not sure what’s going on.

Profile
 
 
Posted: 04 April 2010 06:53 PM   [ Ignore ]   [ # 22 ]  
Summer Student
Total Posts:  10
Joined  02-26-2010
Deadly - 01 April 2010 03:33 PM

Oddly, this only seems to happen in Firefox, not Safari?

I don’t see this happening for me. Anyone else?

Profile
 
 
Posted: 05 April 2010 05:35 AM   [ Ignore ]   [ # 23 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  316
Joined  05-08-2008

OK Hello friends,

the FB Files have some major issues with their own cookie mangement system.
I’m pretty sure i saw it on their issues list as unsolved item.

The problem is when the session somehow expires, the info about the old cookie
gets lost and since it can’t be accessed it throws up an error.

for this unstability i use the FB Connect library only to “ease” up the creation
of the account on my system and DONT use it as a login substitute.

i wish there would be a “plug & play” library that we could use.

have fun

Profile
 
 
Posted: 13 April 2010 06:40 AM   [ Ignore ]   [ # 24 ]  
Summer Student
Total Posts:  10
Joined  02-26-2010

Just added the line to unset facebook data from the session cookie when the session no longer exists:

$this->_obj->session->unset_userdata(‘facebook_user’);

<?php
/**
* CodeIgniter Facebook Connect Library (http://www.haughin.com/code/facebook/)
*
* Author: Elliot Haughin (http://www.haughin.com), elliot@haughin.com
*
* VERSION: 1.0 (2009-05-18)
* LICENSE: GNU GENERAL PUBLIC LICENSE - Version 2, June 1991
*
**/


    
include(APPPATH.'libraries/facebook-client/facebook.php');

    class 
Facebook_connect {

        
private $_obj;
        private 
$_api_key        NULL;
        private 
$_secret_key    NULL;
        public     
$user             NULL;
        public     
$user_id         FALSE;
        public     
$info            NULL;
        
        public 
$fb;
        public 
$client;

        function 
Facebook_connect()
        
{
            $this
->_obj =& get_instance();

            
$this->_obj->load->config('facebook');
            
$this->_obj->load->library('session');
            
            
$this->_api_key        $this->_obj->config->item('facebook_api_key');
            
$this->_secret_key    $this->_obj->config->item('facebook_secret_key');

            
$this->fb = new Facebook($this->_api_key$this->_secret_key);
            
            
$this->client $this->fb->api_client;
                        
            if(
$this->fb->get_loggedin_user()) {
                
try {
                    
//Get some sample data from facebook, you can do whatever you want here really..
                    
$this->user_id $this->client->fql_query('SELECT uid, pic_square, first_name FROM user WHERE uid = ' $this->fb->get_loggedin_user());
                
catch (Exception $ex{
                    
//Need to destroy the session. This is the important part!
                    
$this->fb->clear_cookie_state();
                
}
                $this
->user_id $this->fb->get_loggedin_user();                
            
else {
                $this
->user_id NULL;
            
}
            

            $this
->_manage_session();

            if ( 
$this->user_id !== NULL )
            
{
                
            }
        }

        
private function _manage_session()
        
{
            
if($this->_obj->session->userdata('facebook_user')){
                $user 
$this->_obj->session->userdata('facebook_user');
            
}else{
                $user
=FALSE;
                
}

            
if ( $user === FALSE && $this->user_id !== NULL )
            
{
                $profile_data 
= array('uid','first_name''last_name''name''locale''pic_square''profile_url''email');
                
$info $this->fb->api_client->users_getInfo($this->user_id$profile_data);
                if (isset(
$info[0])) {
                        $user 
$info[0];
                        
$this->_obj->session->set_userdata('facebook_user'$user);
                    
}
            }
            
elseif ( $user !== FALSE && $this->user_id === NULL )
            
{
                
// Need to destroy session
        
$this->_obj->session->unset_userdata('facebook_user');

            
}

            
if ( $user !== FALSE )
            
{
                $this
->user $user;
            
}
        }
    } 
Profile
 
 
Posted: 06 May 2010 07:05 AM   [ Ignore ]   [ # 25 ]  
Summer Student
Total Posts:  4
Joined  01-18-2010

I am using the above file for my facebook_connect.php and using the remaining files from Elliot Haughin’s library (http://www.haughin.com/code/facebook).

But I get the following error message :

Fatal error: Call to undefined method Facebook::clear_cookie_state()

I saw that such a function is not present in the facebook-client/facebook.php file.
Could someone post me the facebook-client/facebook.php file to be used with this ?

Profile
 
 
Posted: 12 May 2010 04:12 AM   [ Ignore ]   [ # 26 ]  
Summer Student
Avatar
Total Posts:  5
Joined  08-29-2007
Jayakrishnan - 06 May 2010 11:05 AM

I am using the above file for my facebook_connect.php and using the remaining files from Elliot Haughin’s library (http://www.haughin.com/code/facebook).

But I get the following error message :

Fatal error: Call to undefined method Facebook::clear_cookie_state()

I saw that such a function is not present in the facebook-client/facebook.php file.
Could someone post me the facebook-client/facebook.php file to be used with this ?

its here http://wiki.developers.facebook.com/index.php/PHP

direct download link http://pearhub.org/get/facebook-0.1.0.tgz

Profile
 
 
Posted: 12 May 2010 10:15 AM   [ Ignore ]   [ # 27 ]  
Summer Student
Total Posts:  4
Joined  01-18-2010

Thanks. Is there any way i can access the email or proxied email of the facebook user ?

Profile
 
 
Posted: 21 May 2010 02:16 PM   [ Ignore ]   [ # 28 ]  
Summer Student
Total Posts:  4
Joined  05-14-2010

We are supposed to get extended permissions doing this:

<fb:login-button perms="user_location, user_hometown"></fb:login-button

But… it is not working… i tried this too..

<fb:prompt-permission perms="user_location, user_hometown">texttexttexttext</fb:prompt-permission

But somehow while loading the page, “textextext…” DISAPPEARS!! -.-

Anyone managed to get extra permissions in ANY way? i need it for my app (and i only need user_location and user_hometown -.-)

Yes, im using Elliot’s library for codeigniter.

Really thanks in advance, this is killing me.

Edit: i updated the facebook libraries and now fb:promt-permission works, but… you know, the main idea is that being asked the first time while trying to log in.

Edit2: Also.. im getting this “error”, after i logout, my session information is still avaible untill i refresh again, i mean, im doing print_r($user); so i can test if the info is avaible or not, it still prints after i logout, but it doesnt after i manually refresh (yes, im cleaning and unsetting and etc my sessions as stated at previous posts) Please help.

Edit3: Sigh, also my login button is not being translated? and my script is correctly setup: http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/es_LA

Why some tutorials follow different scripts and differents ways to do it? this script: http://connect.facebook.net/es_LA/all.js tranlates everything properly but it doesnt work with our library.

Im really lost tired of trying different ways. With Elliot’s library connecting is really easy… but api calls, calling the graph api.. no.

Profile
 
 
Posted: 28 May 2010 03:45 PM   [ Ignore ]   [ # 29 ]  
Summer Student
Total Posts:  1
Joined  05-18-2010

Hey everybody!

Im trying to fix the problem the last 5 days and the fatal error still appears. Its really weird, because after I tryed Perkys solution it immidately worked fine - but the next day the error appeared again!

Has someone maybe another tipp, what i can do to solve the problem!

The only thing i use on my page is the fb:login button

EDIT:It just startet working - grin

Profile
 
 
Posted: 29 July 2010 04:00 PM   [ Ignore ]   [ # 30 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  415
Joined  10-20-2008

Did anyone get extended permissions to work with this?

 Signature 

Mat-Moo
Image moo - the easy to use image library!
MatMoo.com!
E-Mail Remind - Free reminders by email
Printfetti - Your photos on confetti!

Profile
 
 
   
2 of 3
2