Facebook PHP SDK & Codeigniter: Unable to load con

2019-08-26 01:22发布

my config/facebook.php

$config['appId']        = 'XXXXX';
$config['secret']       = 'XXXX';
$config['fb_access_token'] = 'XXXXXX';

my controller:

$this->load->library('Facebook');  
echo $this->config->item('fb_access_token');

Outputs nothing for the the token? yet I know the library is loading as I can call getAppID ok. It just doesn't seem to be loading this config file.

Also tried this from the controller:

$this->config->load("facebook",TRUE);
$config = $this->config->item('facebook');
$this->load->library('facebook', $config);

1条回答
\"骚年 ilove
2楼-- · 2019-08-26 01:37

The proper way to load the library:

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

You can set the access token only afterwards:

$this->facebook->setAccessToken($this->config->item('fb_access_token'));
查看更多
登录 后发表回答