As i have a testing environment and a development one. I needed it to be in the wonderful application.ini where i can easily change between environments.
In the application.ini I have.
[testing : production]Now i want in the bootstrap to initialize the facebook object.
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.db.adapter = "mysqli"
resources.db.params.host = "localhost"
resources.db.params.username = "dbuser"
resources.db.params.password = "########"
resources.db.params.dbname = "########"
facebook.apikey = ########23415733; (NOTICE should be integer)
facebook.secret = ########66491221; (NOTICE should be integer)
[development : production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
resources.db.adapter = "mysqli"
resources.db.params.host = "localhost"
resources.db.params.username = ""########"
resources.db.params.password = ""########""
resources.db.params.dbname = "########"
facebook.apikey = ########2341577d; (NOTICE should be integer)
facebook.secret = ########6649128; (NOTICE should be integer)
$aConfig = $this->getOptions();
require_once(APPLICATION_PATH .'/../library/facebook-platform/php/facebook.php');
$facebook = new Facebook($aConfig['facebook']['apikey'],$aConfig['facebook']['secret']);
Zend_Registry::set('facebook', $facebook); // register the object .
Now i can use in my application like so.
$facebook = Zend_Registry::get('facebook');
Take care,
Great article. I saw a few other methods posted online for using the application.ini and facebook API but yours was probably the most logically laid out and easiest to understand. Thanks!
ReplyDelete