CodeIgniter中的敏感数据

I am building a CodeIgniter 2.1.3 application that uses the Twitter OAuth API for several functions. I have all my tokens for the Twitter API in a separate file, app_tokens.php, which is ignored by git. What function do I use to include this file in my Tweet class?

app_tokens.php:

<?php 
$consumer_key = 'xxxxxxxxxxxxxxxxxxxxxx';
$consumer_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$user_token = 'xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxx';
$user_secret = 'xxxxxxxxxxxxxxxxxxxx';
?>

Thanks!

duanpin5168
duanpin5168 Pekka是对的...一个简单的谷歌搜索“在PHP中包含文件”会显示一个..
7 年多之前 回复
dsa99349
dsa99349 php.net/include?
7 年多之前 回复

2个回答



https://www.codeigniter.com/user_guide/libraries/config.html 。 谢谢你的帮助!</ p>
</ div>

展开原文

原文

Found my answer in https://www.codeigniter.com/user_guide/libraries/config.html. Thanks for the help though!

dream0614
dream0614 +1非常感谢Mimo。 我有同样的问题,但你的链接帮助我解决了问题!
7 年多之前 回复
dph6308
dph6308 啊啊,你打败了我36秒= oP
7 年多之前 回复

Create a file called tweet.php in your application/config folder and put this in it replacing the X's with your real data of course:

<?php

$config['consumer_key'] = 'xxxxxxxxxxxxxxxxxxxxxx';
$config['consumer_secret'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$config['user_token'] = 'xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxx';
$config['user_secret'] = 'xxxxxxxxxxxxxxxxxxxx';

Then in your Tweet class load that config file by doing this:

$this->config->load('tweet');

Then you can access those config values like so:

$this->config->item('consumer_key');
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐