0

I searched here and in the web for my problem, but i didn't found any soluation, this make me crazy, i don't know whats the proplem. the propble is, getUser() function always return 0.

here the my library:

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

    class Fbconnect extends Facebook{

        public $user_id = null;
        public $user = null;

        function Fbconnect(){
            $ci =& get_instance();
            $ci->load->config('facebook',true);
            $config = $ci->config->item('facebook');
            parent::__construct($config);
            $this->user_id = $this->getUser();
            $me = null;
            if($this->user_id){
                try{
                    $me = $this->api('/me');
                    $this->user = $me;
                }catch(FacebookApiException $e){
                    error_log($e);
                }
            }
        }
    }

and this is the controller

function facebookRequest(){
        $this->load->library('fbconnect');
        $data = array(
            'redirect_uri' => base_url().'home/handleFacebookRequest',
            'scope' => 'email'
        );

        redirect($this->fbconnect->getLoginUrl($data));
    }

    function handleFacebookRequest(){
        $this->load->library('fbconnect');
        if($this->fbconnect->user){
            echo '<pre>';
            print_r($this->fbconnect->user);

        }else{
            echo "Login operation faild, try again later";
        }
    }

and i used a config file to store the appId and secrect

$config = array(
    'appId' => 'xxxxxx',
    'secret' => 'xxxxxxxxxxxxxxxxxxxx',
    'cookie' => true
);
Mohamed Nagy
  • 1,054
  • 1
  • 11
  • 31

1 Answers1

1

In your plugin APPPATH.'libraries/facebook.php' (that i believe you downloaded from facebook) there is a function errorLog($msg), this function logs the errors in php error log (or apache error log rather) If you don't want to hassle, with rewrting that to CI error logging, you can just echo that $msg and see if there are any errors. Debug accordingly.

If you haven't changed ANYTHING in the core files you downloaded, my bet is that your curl request in function makeRequest(args[..]) needs a CURLOPT_SSL_VERIFYPEER set to false, or rather this line: $opts[CURLOPT_SSL_VERIFYPEER] = false; needs to be added

Elijan
  • 1,406
  • 1
  • 8
  • 11