Fatal error: Class 'OAuth' not found in

前端 未结 4 1732
别跟我提以往
别跟我提以往 2021-02-08 03:28

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/vh

相关标签:
4条回答
  • 2021-02-08 03:57

    For php 5.6... First the disclaimer: you need to migrate to the latest stable php 7 ASAP and not run php 5.6! But if that's just not possible quite yet, this might help Ubuntu 16.04 users. This assumes you have the ondrej/php ppa.

    sudo apt-get update
    sudo apt-get install libpcre3-dev
    sudo apt-get install php-pear            # * see note below 
    sudo apt-get install php5.6-dev          # for phpize
    sudo pecl install oauth-1.2.3
    
    # now add "extension=oauth.so" (sans quotes) to the 
    # "Dynamic Extensions" area in /etc/php/5.6/apache2/php.ini
    

    * Per this post https://askubuntu.com/a/756186/343695 "php-pear pull[s] just CLI PHP 7.0 (php7.0-cli) and that's harmless" That comment was made in 2016 and may no longer be true. I didn't see any problems...yet.

    0 讨论(0)
  • 2021-02-08 03:58

    OAuth is a PECL extension it must be compiled into PHP or compiled as an extension.

    • http://us3.php.net/manual/en/oauth.installation.php
    • http://pecl.php.net/package/oauth

    Most servers will not have it by default since it really is not something everyone would likely use. You can ask your host to either install it or if you have the ability compile it on server if using CGI as I did. If you run phpinfo(); and look for the word OAuth it will show up if you have it, otherwise you don't.


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

    0 讨论(0)
  • 2021-02-08 03:58

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

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

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

    0 讨论(0)
  • 2021-02-08 04:01
    sudo apt-get update
    sudo apt-get install php-oauth
    sudo service apache2 restart
    
    0 讨论(0)
提交回复
热议问题