Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Fatal error: Class 'OAuth'

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

like image 272
iLearnSomethingNew Avatar asked Jan 26 '26 01:01

iLearnSomethingNew


2 Answers

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.

like image 191
Nielsvh Avatar answered Jan 28 '26 18:01

Nielsvh


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.

like image 21
Tom van der Woerdt Avatar answered Jan 28 '26 18:01

Tom van der Woerdt