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!
Found my answer in https://www.codeigniter.com/user_guide/libraries/config.html. Thanks for the help though!
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');