Facebook PHP SDK not loading as a library in CodeI

2019-06-06 12:03发布

I'm having a problem simply loading the Facebook PHP SDK (v3.1.1) as library in CodeIgniter 2.0.

1) I've put the latest Facebook SDK files ('facebook.php', 'base_facebook.php', and 'fb_ca_chain_bundle.crt' ) into my application/libraries folder.

2) I've changed the filename of 'facebook.php' to 'Facebook.php'.

3) In my controller, I have the following code:

$fb_config = array(
   'appId'  => 'XXXXXXX',          
   'secret' => 'XXXXXXX'
  );
$this->load->library('facebook', $fb_config);

$this->load->view('home_view');

But I just get an error and the View does not get loaded.

If I comment out the line

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

then the View loads correctly, so I know the problem is here.

4) If I try to autoload the facebook library, I get similar results.

Can anyone help? Thanks.

1条回答
The star\"
2楼-- · 2019-06-06 12:10

I figured out the problem.

I was missing the PHP cURL extension, so the code aborted in the “base_facebook.php” file when it checked if I had cURL installed. Not sure why I did not see any sign of a PHP Fatal Error.

After I installed this package, all is well.

查看更多
登录 后发表回答