简体   繁体   中英

Facebook PHP SDK & Codeigniter: Unable to load config

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);

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'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM