oauthphp-extensionyahoo-api

How to install and load OAuth extension to avoid Uncaught Error message


I'm trying to set up OAuth to use between my website and Yahoo Fantasy Sports but getting the error message "Fatal error: Uncaught Error: Class 'OAuth' not found". I'm completely new to OAuth and the process described below is the first time I'm dabbling with this.

I've registered for a Yahoo API key and secret and am using them in this code in PHP to try to set up a basic test connection:

$o = new OAuth( $consumer_key, $consumer_secret,
                OAUTH_SIG_METHOD_HMACSHA1,
                OAUTH_AUTH_TYPE_URI );

Having searched here, I know I need an OAuth extension and PHPoAuthLib was recommended in another post. I've followed the instructions to install it on the web server via Composer (which basically seemed to be composer require lusitanian/oauth in SSH) but am still getting the "Uncaught Error" message. The php/ext folder on my server is empty and I'm don't know if that is a bad sign.

I've run a phpinfo() file on the server and it does not show oAuth. I've also read that I probably need to load the extension in a php.ini file on my server but I don't know exactly how I would do that for the PHPoAuthLib extension. I tried extension=oauth or extension=oauth.so but didn't seem to work.

Any help would be much appreciated! I'm not wedded to that particular extension (I've also seen a recommendation elsewhere for a Python Yahoo OAuth extension but I know nothing about Python or using 'pip')... I just feel like I'm going around in circles trying to figure out each step.


Solution

  • After trying both PHP and Python OAuth extensions mentioned above, it turned out my web hosting provider prevents custom installations via SSH on shared web hosting for security reasons, but was able to install the HTTP OAuth PEAR module that is available via cPanel to enable OAuth to be used.