Warning: Use of undefined constant OAUTH_REQENGINE_CURL
On an Ubuntu server (Ubuntu 20.04.2 LTS) when running a PHP script, I get the following error.
1 |
Warning: Use of undefined constant OAUTH_REQENGINE_CURL - assumed 'OAUTH_REQENGINE_CURL' (this will throw an Error in a future version of PHP |
On checking phpinfo, I get
1 |
Request engine support php_streams |
curl is missing in “Request engine support”.
This is because the default php-oauth package does not support curl. To fix, uninstall php-oauth and install oauth package using pecl.
Uninstall pcel
1 |
apt install php-oauth -y |
install curl dev package
1 2 |
apt install libcurl4-gnutls-dev ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl |
Install PHP PECL
1 |
apt install php-pear |
Install oAuth
1 |
pecl install oauth |
Edit php.ini file
1 |
vi /etc/php/7.4/cli/php.ini |
Add at end of the file
1 |
extension=oauth.so |
You need to do the same for Apache and php-fpm php.ini files located at
1 2 |
/etc/php/7.4/apache2/php.ini /etc/php/7.4/fpm/php.ini |
7.4 is for PHP version 7.4. Change this to whatever PHP version you have on your server. After making the change, phpinfo() page shows curl
See php