Facebook PHP SDK & Codeigniter: Unable to load config

房东的猫 提交于 2019-12-25 04:55:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!