Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Class 'OAuth' not found in

Tags:

php

I'm trying to connect to the LinkedIn API but everytime 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'm using a free server on 000WebHost and I've read that free servers sometimes don't support OAuth. I've tried it on another free server and I get the same error message, so my question is how can I check whether the server supports the use of 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();

The keys are just replaced with the ones on the LikedIn Developers Getting Started Guide.

Thank you in advance for your help.

like image 857
Lehan Coetzee Avatar asked Dec 11 '12 14:12

Lehan Coetzee


1 Answers

sudo apt-get update
sudo apt-get install php-oauth
sudo service apache2 restart
like image 149
Serhii Vasko Avatar answered Oct 23 '22 09:10

Serhii Vasko