Welcome Guest, Not a member yet? Register   Sign In
Facebook Connect with codeignitor
#21

[eluser]sigsauer[/eluser]
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!
#22

[eluser]Deadly[/eluser]
It's much better for me as well, with one issue remaining after a session expires:

Code:
Severity: Notice

Message: Uninitialized string offset: 0

Filename: libraries/Facebook_connect.php

Line Number: 82

Edit: line 82 is the last line here:
Code:
$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.
#23

[eluser]sigsauer[/eluser]
[quote author="Deadly" date="1270153980"]

Oddly, this only seems to happen in Firefox, not Safari?
[/quote]

I don't see this happening for me. Anyone else?
#24

[eluser]The Wizard[/eluser]
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
#25

[eluser]sigsauer[/eluser]
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');

Code:
<?php
/**
* CodeIgniter Facebook Connect Library (http://www.haughin.com/code/facebook/)
*
* Author: Elliot Haughin (http://www.haughin.com), [email protected]
*
* 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;
            }
        }
    }
#26

[eluser]Jayakrishnan[/eluser]
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 ?
#27

[eluser]khalil Majdalawi[/eluser]
[quote author="Jayakrishnan" date="1273161959"]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 ?[/quote]

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

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

[eluser]Jayakrishnan[/eluser]
Thanks. Is there any way i can access the email or proxied email of the facebook user ?
#29

[eluser]Cryorus[/eluser]
We are supposed to get extended permissions doing this:

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

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

Code:
<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....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.
#30

[eluser]Unknown[/eluser]
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 - :-)




Theme © iAndrew 2016 - Forum software by © MyBB