问题
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:
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'));
来源:https://stackoverflow.com/questions/14470194/facebook-php-sdk-codeigniter-unable-to-load-config