Reputation: 857
I am using the PECL OAuth library for PHP which I installed correctly (well, I'm doubting that now). I use it for authentication before querying the LinkedIn API. In my code I create an OAuth object as in the example here, see bottom. It gets the tokens, authorizes the user after he logged in, and successfully fetches data. But the funny thing is that it only works when I run the .php file through my browser (hosted in apache).
When I try to compile the code from the commandline the compiler says: PHP Fatal error: Class 'OAuth' not found in xxx.php on line 15
Obviously I already edited the php.ini to contain the following (or it would not work on the webpage): extension=/usr/lib/php5/20090626/oauth.so
But when I type 'php -m' in the commandline I dont see the oauth module in the list. I have tried getting the filename/location by inserting these lines after making an instance of the OAuth object
$oauthc = new OAuth($oauth['linkedin']['consumerkey'], $oauth['linkedin']['consumersecret'],OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$reflector = new ReflectionClass("OAuth");
$fn = $reflector->getFileName();
echo "[".dirname($fn)."]";
But this only returned the 2 brackets. I have no clue why it apparently works in the browser. Hopefully somebody can help me out.
Upvotes: 1
Views: 1321
Reputation: 5523
PHP can use different php.ini
config files depending on what SAPI is currently in use. For example, there can be files (depends on linux distribution):
/etc/php5/cli/conf.d/*.ini
-> loaded when run in CLI mode/etc/php5/apache2/conf.d/*.ini
-> loaded when run as an Apache moduleSo, probably your module is getting loaded when PHP runs as an Apache module, and not loaded for CLI
Upvotes: 1