Hi, i have this bas_facebook.php to login with facebook on my website, but it gives me error with the exception:

if (!function_exists('curl_init')) {
  throw new Exception('Facebook needs the CURL PHP extension.');
}
if (!function_exists('json_decode')) {
  throw new Exception('Facebook needs the JSON PHP extension.');
}

/**
 * Thrown when an API call returns an exception.
 *
 * @author Naitik Shah <naitik@facebook.com>
 */
class FacebookApiException extends Exception
{
  /**
   * The result from the API server that represents the exception information.
   */
  protected $result;

  (...)

This are the errors:

( ! ) Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\wamp\www\facebook\lib\base_facebook.php on line 19
( ! ) Exception: Facebook needs the CURL PHP extension. in C:\wamp\www\facebook\lib\base_facebook.php on line 19

Recommended Answers

All 2 Replies

That error means that you do not have your CURL extension enabled. Are you running a local server or a hosted server? If you are using a local server, you can navigate to the folder in which your php.ini file resides (for me that's "\xampp\php"), open up that php.ini file, ctrl+f to find "curl" and remove the semicolon (";") in front of that line (if a semicolon is there) to enable the CURL extension. You will have to restart your server for changes to take effect.

Curl is apparently not enabled in your website. You need it for this API.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.