0

I am trying to integrate facebook SDK with a codeigniter website. I have used composer to install the files with the composer.json file with the code provided in the facebook documentation. I have looked at multiple other potentially similar problems on stackoverflow and around and came across examples like this:

http://metah.ch/blog/2014/05/facebook-sdk-4-0-0-for-php-a-working-sample-to-get-started/#post-937 CodeIgniter Facebook SDK 4 with Composer Error: Class 'Facebook\FacebookSession' not found with the facebook PHP SDK

The error I recieve is:

Fatal error: Uncaught exception 'Facebook\FacebookSDKException' with message 'You must provide or set a default application id.' in ....

I have the following code in my controller:

public function login()
    {
         $fb_config = array(
        'appId'  => 'xxxxx',
        'secret' => 'xxxx'
    );

    $this->load->library('facebook', $fb_config);

    $user = $this->facebook->getUser();

    if ($user) {
        try {
            $data['user_profile'] = $this->facebook
                ->api('/me');
        } catch (FacebookApiException $e) {
            $user = null;
        }
    }

    if ($user) {
        $data['logout_url'] = $this->facebook
            ->getLogoutUrl();
    } else {
        $data['login_url'] = $this->facebook
            ->getLoginUrl();
    }
   $this->load->view('templates/header');
   $this->load->view('user/login',$data);

    }

I have tried adding require and use and session start at the top of the class but the issue persists.

Community
  • 1
  • 1
eGlu
  • 697
  • 11
  • 22
  • `$this->load->library('facebook', $fb_config);` – that would load a class named `facebook` – but version 4 of the SDK does not have a class of that name. – CBroe Nov 20 '14 at 19:34
  • Sigh.... Thanks for the spot, integrating it was a b***h. fixed it up now. Shot CBroe \,,/(*_*)\,,/ – eGlu Nov 21 '14 at 21:14
  • Did you get solution? @eGlu – PC. Apr 18 '15 at 18:09
  • Ye, was working with two different versions of the FB PHP SDK. As CBroe pointed out. I was using version 4 but had some old code that was deprecated. Just had to replace that and was all good. – eGlu May 11 '15 at 15:54

0 Answers0