简体   繁体   English

Facebook PHP SDK和Codeigniter:无法加载配置

[英]Facebook PHP SDK & Codeigniter: Unable to load config

my config/facebook.php 我的配置/ 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. 但是我知道库正在加载,因为我可以调用getAppID。 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'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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