问题
I searched the site for hours looking for answer and nothing helped me. I’ve installed PHP/Apache2/PECL/OAuth and edited php.ini for extension=oauth
. I get this error everything I type "php example.php" I'd set the token and everything required in example.php
PHP Fatal error: Class 'OAuth' not found in /home/twitter/TwitterAutoReply.php on line 22
My php files is example.php and TwitterAutoReply.php
https://raw.github.com/gist/820281/303a61ee9b324070e803e51806552e64fccfdd4c/example.php and https://gist.github.com/raw/820281/6bf1b6d78dd05daef319ce84a88eedf139a44b5a/TwitterAutoReply.php
回答1:
From the error, you're not importing the oauth package in you php.ini file. For ubuntu, you need to install oauth:
sudo pecl install oauth
Then include the oauth package in your php.ini. If you don't know where the file is, you can use:
sudo find / -name "oauth.so"
Using the path to the extension add the following to your php.ini:
extension=/path/to/oauth/package/oauth.so
Restart apache and try again.
回答2:
Ensure that the extension is actually loaded. To verify that it is, simply ask PHP something about the OAuth extension, in a command like:
php --re oauth
If this doesn't show information about the module but instead gives an error, you'll know that it's not loaded. Additionally you could simply list all loaded modules with php -m
.
Try manually loading the extension by using -z oauth
in your command. Example: php -z oauth example.php
. If that works, you didn't edit your php.ini correctly.
回答3:
The command php --re oauth
solved my issue.
Seems there was some miss coding with php.ini
. the command gives me error, I removed those lines and re-install oauth, restarted httpd and it loads that extension successfully.
来源:https://stackoverflow.com/questions/8370362/php-fatal-error-class-oauth