Hi all,

I installed drupal for facebook and when I click on my administer page instead of showing the page it displays the following message:
"Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\wamp\www\movieland\sites\all\libraries\facebook-php-sdk\src\facebook.php:4 Stack trace: #0 C:\wamp\www\movieland\sites\all\modules\fb\fb.install(53): include() #1 [internal function]: fb_requirements('runtime') #2 C:\wamp\www\movieland\includes\module.inc(483): call_user_func_array('fb_requirements', Array) #3 C:\wamp\www\movieland\modules\system\system.admin.inc(1703): module_invoke_all('requirements', 'runtime') #4 C:\wamp\www\movieland\modules\system\system.admin.inc(21): system_status(true) #5 [internal function]: system_main_admin_page() #6 C:\wamp\www\movieland\includes\menu.inc(348): call_user_func_array('system_main_adm...', Array) #7 C:\wamp\www\movieland\index.php(18): menu_execute_active_handler() #8 {main} thrown in C:\wamp\www\movieland\sites\all\libraries\facebook-php-sdk\src\facebook.php on line 4"

So far this is the only problem I noticed. All other admin sections seems operational.

I use only fb.module (like button on my content nodes)and followed the installation instructions (README file - 1.Download from http://github.com/facebook/php-sdk. Extract the files, and place them in sites/all/libraries/facebook-php-sdk, 2.Your theme needs the following attribute at the end of the tag: xmlns:fb="http://www.facebook.com/2008/fbml")
So my html now looks like this :
print $language->language " lang=" print $language->language " dir=" print $language->dir ">
print $language->language " lang=" print $language->language " dir=" print $language->dir " xmlns:fb="http://www.facebook.com/2008/fbml">

Like button displays normally on my nodes and seems operational except on frontpage where i display many nodes (teaser views of 1 content type) using ajax. When i click on like button of a node teaser view it "likes" all my nodes...
Also I see no new post on my facebook page unless i comment when I "like".
Should I post the last 2 as separate issues?(sorry I am new in posting issues)

Any suggestions?
Thanks in advance

Comments

funkycamel’s picture

Assigned: funkycamel » Unassigned
funkycamel’s picture

also status reports shows the same message:

"Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\wamp\www\movieland\sites\all\libraries\facebook-php-sdk\src\facebook.php:4 Stack trace: #0 C:\wamp\www\movieland\sites\all\modules\fb\fb.install(53): include() #1 [internal function]: fb_requirements('runtime') #2 C:\wamp\www\movieland\includes\module.inc(483): call_user_func_array('fb_requirements', Array) #3 C:\wamp\www\movieland\modules\system\system.admin.inc(1703): module_invoke_all('requirements', 'runtime') #4 C:\wamp\www\movieland\modules\system\system.admin.inc(21): system_status(true) #5 [internal function]: system_main_admin_page() #6 C:\wamp\www\movieland\includes\menu.inc(348): call_user_func_array('system_main_adm...', Array) #7 C:\wamp\www\movieland\index.php(18): menu_execute_active_handler() #8 {main} thrown in C:\wamp\www\movieland\sites\all\libraries\facebook-php-sdk\src\facebook.php on line 4"

funkycamel’s picture

The same when i try to run cron

funkycamel’s picture

After uninstalling the module and deleting it, it seems that everything is back to normal.

Please advice or suggest another module.
The only thing I want to do is to add a "share and/or like" button on my content type nodes

Dave Cohen’s picture

Title: drupal for facebook blocks my administer page » Facebook needs the CURL PHP extension
Status: Active » Fixed

http://drupal.org/node/928034

I don't see how the error message could be any clearer.

funkycamel’s picture

yes you have a point.
thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

NancyDru’s picture

Status: Closed (fixed) » Active

You can re-close after answering. I had this module installed for several days and until just now, when I enabled the jQuery Update and Superfish modules, it was fine without the extension. What would those modules have done to mess up FB?

Dave Cohen’s picture

I have no idea, but I don't see how it was actually working correctly without CURL.

therobyouknow’s picture

http://drupal.org/node/928034

I don't see how the error message could be any clearer.

I wish the solution was as clear - I'll do my bit to contribute to making the solution to the error message as clear as that - it isn't at the moment.

I'm not directing my comments at anyone and I say this because there does not seem to be a definitive approach to installing cURL support for PHP:

  • The official documentation is out-of-date and downvoted: http://us.php.net/manual/en/curl.setup.php (and same on the 'new' beta site, before anyone asks)
  • Google searches throw up people with .dll issues on Windows-based server stacks (WAMP). No good if like me you are running Linux.

I'm seeing this problem in Drupal 7 but I am aware that the original poster was using Drupal 6.

Here's what I tried:

Installed PHP5-Curl:

root@li473-171:# apt-get install php5-curl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  php5-curl
0 upgraded, 1 newly installed, 0 to remove and 70 not upgraded.
Need to get 28.0 kB of archives.
After this operation, 118 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main php5-curl amd64 5.3.10-1ubuntu3.7 [28.0 kB]
Fetched 28.0 kB in 0s (112 kB/s)     
Selecting previously unselected package php5-curl.
(Reading database ... 29064 files and directories currently installed.)
Unpacking php5-curl (from .../php5-curl_5.3.10-1ubuntu3.7_amd64.deb) ...
Setting up php5-curl (5.3.10-1ubuntu3.7) ...
root@li473-171:#

restarted the webserver (I'm guessing this might be needed presumably to see/'pick-up' the changes:
service nginx restart

Enabled the modules I need:
root@li473-171:# drush en fb, fb_app, fb_connect

Cleared all caches:

root@li473-171:# drush cc all

'all' cache was cleared

Visited the admin/config page and still got the error

Exception: Facebook needs the CURL PHP extension. in require_once() (line 19 of ../sites/all/libraries/facebook-php-sdk/src/base_facebook.php).
The website encountered an unexpected error. Please try again later.

Dave Cohen’s picture

I don't know about your variant of linux but on archlinux I have to uncomment the curl line in php.ini.

Trying including the name of your linux distribution (which you did not mention here) in your google search.

Homotechsual’s picture

Looks like you're running ubuntu:

For pre 12.04:

sudo apt-get install php5-curl
sudo service apache2 restart

For 12.04 or later:

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
sudo service apache2 restart

You should double check your PHP.ini file to ensure that the curl extension is indeed enabled before restarting apache but curl will NOT be working until you restart Apache.

therobyouknow’s picture

Still no luck afraid to say but thank you for your input so far, MJCO. I have captured my attempts at your instructions below:

Yes, indeed I am using Ubuntu (Dave Cohen asked this as well - thanks for asking Dave, good question)

I did the following to find out which version I am on:

root@li473-171:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"

So on that basic I ran your commands for 12.04 or later:

root@li473-171:~# sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libcurl4-openssl-dev' instead of 'libcurl3-dev'
php5-curl is already the newest version.
The following extra packages will be installed:
  comerr-dev krb5-multidev libgcrypt11 libgcrypt11-dev libgnutls-dev
  libgnutls-openssl27 libgnutls26 libgnutlsxx27 libgpg-error-dev libgssrpc4
  libidn11-dev libkadm5clnt-mit8 libkadm5srv-mit8 libkdb5-6 libkrb5-dev
  libldap-2.4-2 libldap2-dev libp11-kit-dev librtmp-dev libtasn1-3-dev
  pkg-config
Suggested packages:
  doc-base krb5-doc libcurl3-dbg rng-tools libgcrypt11-doc gnutls-doc
  gnutls-bin krb5-user
The following NEW packages will be installed:
  comerr-dev krb5-multidev libcurl4-openssl-dev libgcrypt11-dev libgnutls-dev
  libgnutls-openssl27 libgnutlsxx27 libgpg-error-dev libgssrpc4 libidn11-dev
  libkadm5clnt-mit8 libkadm5srv-mit8 libkdb5-6 libkrb5-dev libldap2-dev
  libp11-kit-dev librtmp-dev libtasn1-3-dev pkg-config
The following packages will be upgraded:
  curl libcurl3 libgcrypt11 libgnutls26 libldap-2.4-2
5 upgraded, 19 newly installed, 0 to remove and 65 not upgraded.
Need to get 5,358 kB of archives.
After this operation, 12.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libgcrypt11 amd64 1.5.0-3ubuntu0.2 [280 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libgnutls26 amd64 2.12.14-5ubuntu3.4 [459 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libgssrpc4 amd64 1.10+dfsg~beta1-2ubuntu0.3 [57.5 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libkadm5clnt-mit8 amd64 1.10+dfsg~beta1-2ubuntu0.3 [38.7 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libkdb5-6 amd64 1.10+dfsg~beta1-2ubuntu0.3 [37.5 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libkadm5srv-mit8 amd64 1.10+dfsg~beta1-2ubuntu0.3 [54.4 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libldap-2.4-2 amd64 2.4.28-1.1ubuntu4.3 [185 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libcurl3 amd64 7.22.0-3ubuntu4.2 [236 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libgnutls-openssl27 amd64 2.12.14-5ubuntu3.4 [21.6 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libgnutlsxx27 amd64 2.12.14-5ubuntu3.4 [22.6 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main curl amd64 7.22.0-3ubuntu4.2 [137 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu/ precise/main comerr-dev amd64 2.1-1.42-1ubuntu2 [42.7 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main krb5-multidev amd64 1.10+dfsg~beta1-2ubuntu0.3 [125 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu/ precise/main pkg-config amd64 0.26-1ubuntu1 [40.9 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu/ precise/main libidn11-dev amd64 1.23-2 [636 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libkrb5-dev amd64 1.10+dfsg~beta1-2ubuntu0.3 [11.0 kB]
Get:17 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libldap2-dev amd64 2.4.28-1.1ubuntu4.3 [492 kB]
Get:18 http://us.archive.ubuntu.com/ubuntu/ precise/main libgpg-error-dev amd64 1.10-2ubuntu1 [23.3 kB]
Get:19 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libgcrypt11-dev amd64 1.5.0-3ubuntu0.2 [363 kB]
Get:20 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libtasn1-3-dev amd64 2.10-1ubuntu1.1 [357 kB]
Get:21 http://us.archive.ubuntu.com/ubuntu/ precise/main libp11-kit-dev amd64 0.12-2ubuntu1 [45.6 kB]
Get:22 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libgnutls-dev amd64 2.12.14-5ubuntu3.4 [546 kB]
Get:23 http://us.archive.ubuntu.com/ubuntu/ precise/main librtmp-dev amd64 2.4~20110711.gitc28f1bab-1 [67.3 kB]
Get:24 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libcurl4-openssl-dev amd64 7.22.0-3ubuntu4.2 [1,078 kB]
Fetched 5,358 kB in 2s (2,594 kB/s)              
(Reading database ... 29067 files and directories currently installed.)
Preparing to replace libgcrypt11 1.5.0-3ubuntu0.1 (using .../libgcrypt11_1.5.0-3ubuntu0.2_amd64.deb) ...
Unpacking replacement libgcrypt11 ...
Preparing to replace libgnutls26 2.12.14-5ubuntu3.2 (using .../libgnutls26_2.12.14-5ubuntu3.4_amd64.deb) ...
Unpacking replacement libgnutls26 ...
Selecting previously unselected package libgssrpc4.
Unpacking libgssrpc4 (from .../libgssrpc4_1.10+dfsg~beta1-2ubuntu0.3_amd64.deb) ...
Selecting previously unselected package libkadm5clnt-mit8.
Unpacking libkadm5clnt-mit8 (from .../libkadm5clnt-mit8_1.10+dfsg~beta1-2ubuntu0.3_amd64.deb) ...
Selecting previously unselected package libkdb5-6.
Unpacking libkdb5-6 (from .../libkdb5-6_1.10+dfsg~beta1-2ubuntu0.3_amd64.deb) ...
Selecting previously unselected package libkadm5srv-mit8.
Unpacking libkadm5srv-mit8 (from .../libkadm5srv-mit8_1.10+dfsg~beta1-2ubuntu0.3_amd64.deb) ...
Preparing to replace libldap-2.4-2 2.4.28-1.1ubuntu4.2 (using .../libldap-2.4-2_2.4.28-1.1ubuntu4.3_amd64.deb) ...
Unpacking replacement libldap-2.4-2 ...
Preparing to replace libcurl3 7.22.0-3ubuntu4.1 (using .../libcurl3_7.22.0-3ubuntu4.2_amd64.deb) ...
Unpacking replacement libcurl3 ...
Selecting previously unselected package libgnutls-openssl27.
Unpacking libgnutls-openssl27 (from .../libgnutls-openssl27_2.12.14-5ubuntu3.4_amd64.deb) ...
Selecting previously unselected package libgnutlsxx27.
Unpacking libgnutlsxx27 (from .../libgnutlsxx27_2.12.14-5ubuntu3.4_amd64.deb) ...
Preparing to replace curl 7.22.0-3ubuntu4.1 (using .../curl_7.22.0-3ubuntu4.2_amd64.deb) ...
Unpacking replacement curl ...
Selecting previously unselected package comerr-dev.
Unpacking comerr-dev (from .../comerr-dev_2.1-1.42-1ubuntu2_amd64.deb) ...
Selecting previously unselected package krb5-multidev.
Unpacking krb5-multidev (from .../krb5-multidev_1.10+dfsg~beta1-2ubuntu0.3_amd64.deb) ...
Selecting previously unselected package pkg-config.
Unpacking pkg-config (from .../pkg-config_0.26-1ubuntu1_amd64.deb) ...
Selecting previously unselected package libidn11-dev.
Unpacking libidn11-dev (from .../libidn11-dev_1.23-2_amd64.deb) ...
Selecting previously unselected package libkrb5-dev.
Unpacking libkrb5-dev (from .../libkrb5-dev_1.10+dfsg~beta1-2ubuntu0.3_amd64.deb) ...
Selecting previously unselected package libldap2-dev.
Unpacking libldap2-dev (from .../libldap2-dev_2.4.28-1.1ubuntu4.3_amd64.deb) ...
Selecting previously unselected package libgpg-error-dev.
Unpacking libgpg-error-dev (from .../libgpg-error-dev_1.10-2ubuntu1_amd64.deb) ...
Selecting previously unselected package libgcrypt11-dev.
Unpacking libgcrypt11-dev (from .../libgcrypt11-dev_1.5.0-3ubuntu0.2_amd64.deb) ...
Selecting previously unselected package libtasn1-3-dev.
Unpacking libtasn1-3-dev (from .../libtasn1-3-dev_2.10-1ubuntu1.1_amd64.deb) ...
Selecting previously unselected package libp11-kit-dev.
Unpacking libp11-kit-dev (from .../libp11-kit-dev_0.12-2ubuntu1_amd64.deb) ...
Selecting previously unselected package libgnutls-dev.
Unpacking libgnutls-dev (from .../libgnutls-dev_2.12.14-5ubuntu3.4_amd64.deb) ...
Selecting previously unselected package librtmp-dev.
Unpacking librtmp-dev (from .../librtmp-dev_2.4~20110711.gitc28f1bab-1_amd64.deb) ...
Selecting previously unselected package libcurl4-openssl-dev.
Unpacking libcurl4-openssl-dev (from .../libcurl4-openssl-dev_7.22.0-3ubuntu4.2_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for install-info ...
Setting up libgcrypt11 (1.5.0-3ubuntu0.2) ...
Setting up libgnutls26 (2.12.14-5ubuntu3.4) ...
Setting up libgssrpc4 (1.10+dfsg~beta1-2ubuntu0.3) ...
Setting up libkadm5clnt-mit8 (1.10+dfsg~beta1-2ubuntu0.3) ...
Setting up libkdb5-6 (1.10+dfsg~beta1-2ubuntu0.3) ...
Setting up libkadm5srv-mit8 (1.10+dfsg~beta1-2ubuntu0.3) ...
Setting up libldap-2.4-2 (2.4.28-1.1ubuntu4.3) ...
Setting up libcurl3 (7.22.0-3ubuntu4.2) ...
Setting up libgnutls-openssl27 (2.12.14-5ubuntu3.4) ...
Setting up libgnutlsxx27 (2.12.14-5ubuntu3.4) ...
Setting up curl (7.22.0-3ubuntu4.2) ...
Setting up comerr-dev (2.1-1.42-1ubuntu2) ...
Setting up krb5-multidev (1.10+dfsg~beta1-2ubuntu0.3) ...
Setting up pkg-config (0.26-1ubuntu1) ...
Setting up libidn11-dev (1.23-2) ...
Setting up libkrb5-dev (1.10+dfsg~beta1-2ubuntu0.3) ...
Setting up libldap2-dev (2.4.28-1.1ubuntu4.3) ...
Setting up libgpg-error-dev (1.10-2ubuntu1) ...
Setting up libgcrypt11-dev (1.5.0-3ubuntu0.2) ...
Setting up libtasn1-3-dev (2.10-1ubuntu1.1) ...
Setting up libp11-kit-dev (0.12-2ubuntu1) ...
Setting up libgnutls-dev (2.12.14-5ubuntu3.4) ...
Setting up librtmp-dev (2.4~20110711.gitc28f1bab-1) ...
Setting up libcurl4-openssl-dev (7.22.0-3ubuntu4.2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@li473-171:~# 

Then I looked to edit php.ini to reference the curl.so shared object, on the basis that the plethora of curl setup documentation out there is for WAMP and there they mention setting up reference to curl.dll in php.ini So given that I am using Linux I would have thought that it would be necessary to do similar here.

So I first find where.php is:

root@li473-171:/usr/lib# php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini

and open it for edit:

vi /etc/php5/cli/php.ini

In the file, in the existing section:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll
;
; ... or under UNIX:
;
;   extension=msql.so
;
; ... or with a path:
;
;   extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.

; The following added by Rob Davis 2013-08-30 for drupal for facebook dependency on php curl
; more details here: https://drupal.org/node/964230#comment-7806995
<code>

I add:

<code>
; The following added by Rob Davis 2013-08-30 for drupal for facebook dependency on php curl
; more details here: https://drupal.org/node/964230#comment-7806995
extension=curl.so

Interestingly, if I run php --ini

I now see:

PHP Warning: Module 'curl' already loaded in Unknown on line 0

In the output:

PHP Warning:  Module 'curl' already loaded in Unknown on line 0
root@li473-171:/usr/lib# php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini

Anyway, I'll 'park' that thought for the time being and proceed...

I then use drush to clear all the caches and run cron
(not sure if these would help, actually, thoughts welcome)

service nginx restart
drush cc all
drush cron

Then re-enable all the modules

drush en fb, fb_app, fb_connect

Still get same error when I visited the admin/config page:

Exception: Facebook needs the CURL PHP extension. in require_once() (line 19 of /var/www/marketplace/sites/all/libraries/facebook-php-sdk/src/base_facebook.php).
The website encountered an unexpected error. Please try again later.

Dave Cohen’s picture

You should double check your PHP.ini file to ensure that the curl extension is indeed enabled before restarting apache but curl will NOT be working until you restart Apache.

Restarted apache?

therobyouknow’s picture

Yes, I missed this out of the instructions, sorry. I'm using nginx but yes, restarted.

therobyouknow’s picture

This problem mysteriously seems to have gone away; a colleague (with a fresh pair of eyes) worked through the steps and it was fine - can view the config page, not the fatal error messages seen.

Thanks for all your inputs.

Dave Cohen’s picture

Status: Active » Fixed

If you figure out exactly what fixed it, let us know.

therobyouknow’s picture

Dave, thanks for following up I would love to get to the root cause, I have no answer for this at the moment as it's not known. But at least, I hope my steps help folks set things up.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

winternett’s picture

> Dave's comment fixed the issue for me - "You should double check your PHP.ini file to ensure that the curl extension is indeed enabled before restarting apache but curl will NOT be working until you restart Apache. "

I opened my php.ini, searched (CTRL+F) for "curl" un-commented the line and re-started Apache. Did not need to uninstall the Facebook modules.