开发者

Pass parameters when autoloading library with CodeIgniter

I am try开发者_JS百科ing to auto load the facebook.php but it requires the app id and secret. Is it possible to pass parameters when auto loading a library in CodeIgniter ?


I recently did a blog post about this very topic.

The official facebook SDK plays very nice with Codeigniter and just requires you use a external config file to accomplish your goals of autoloading...

so you would just place a file facebook.php in your config directory with these contents

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['appId']  = 'YOUR_APP_ID_HERE'; 
$config['secret'] = 'YOUR_APP_SECRET_HERE';

At this point loading the library should pick up this config while autoloading or otherwise.


You can write a wrapper which will pre-initialize lib using config settings and expose it on one of its public members.

http://codeigniter.com/user_guide/libraries/config.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜