Fatal error: class "OAuth" not found in

I try to connect to the LinkedIn API, but every time I try to access it, I get the following error:

Fatal error: Class 'OAuth' not found in / home / vhosts / * / test.php on line 8

I use a free server on 000WebHost, and I read that free servers sometimes do not support OAuth. I tried this on another free server and I get the same error message, so my question is: how to check if the server supports using OAuth?

Here is my code:

// Fill the keys and secrets you retrieved after registering your app $oauth = new OAuth("abcd123456", "efgh987654"); $oauth->setToken("abcd1234-efgh987-9988", "9876abcd-123asdf-1122"); $params = array(); $headers = array(); $method = OAUTH_HTTP_METHOD_GET; // Specify LinkedIn API endpoint to retrieve your own profile $url = "http://api.linkedin.com/v1/people/~"; // By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call // $url = "http://api.linkedin.com/v1/people/~?format=json"; // Make call to LinkedIn to retrieve your own profile $oauth->fetch($url, $params, $method, $headers); echo $oauth->getLastResponse(); 

Keys have just been replaced with keys in the LikedIn Developer's Guide.

Thank you in advance for your help.

+7
source share
3 answers

OAuth is a PECL extension that must be compiled in PHP or compiled as an extension.

Most servers will not have it by default, as this is really not what everyone is likely to use. You can ask your host to either install it, or if you have the opportunity to compile it on the server, if you use CGI, like me. If you run phpinfo (); and look for the word OAuth, it will appear if you have it, otherwise you won’t.


Update: Use https://github.com/Lusitanian/PHPoAuthLib instead of PECL.

+8
source

I use hostgator for hosting and have this problem, so if your host also uses cpanel, you should be able to do what I did.

Go to 1 directory up from the live directory in the File Manager, where you can see "public_html, www, tmp". (Or click on the home folder icon on the left) and there you will find the php.ini file. edit the file with extension=oauth.so to the very end and save it.

Checking phpinfo () after that you should find the "OAuth" section and everything should work fine.

+1
source

Try looking here . There is an example of how to use the associated api through the OAuth php class, rather than the extension.

0
source

All Articles