Patrioticcow
Patrioticcow

Reputation: 27048

how to fix a facebook Fatal error: Uncaught CurlException problem

I've got this error coming from facebook, from time to time:

Fatal error: Uncaught CurlException: 28: connect() timed out! thrown in /var/www/html/xxx/facebook/src/facebook.php on line 614

it breaks my site.

this is the code from facebook.php

if ($result === false) {
  $e = new FacebookApiException(array(
    'error_code' => curl_errno($ch),
    'error'      => array(
      'message' => curl_error($ch),
      'type'    => 'CurlException',
    ),
  ));
  curl_close($ch);
  throw $e;
}

is there a way to fix this? or at lease to degrade gracefully ? thanks

i am thinking to arr a return false; if the $result === true but i don't know if that will fix it

Upvotes: 3

Views: 5343

Answers (2)

Martha Smithers
Martha Smithers

Reputation: 153

I have the same problem since yesterday on all my apps (around 20). It works normal most of the time, but then sometimes instead of loaded page this is what users get (I think it's because of using $me = $facebook->api('/me'); - after I removed that I haven't got that error yet, but the problem now is that I need this in order to get users data).

Upvotes: 2

Magicianeer
Magicianeer

Reputation: 2180

Catch the exception to avoid the immediate Fatal Error kill, but you still need to adjust to facebook data not being available. See http://www.php.net/catch

try {
    // facebook code
} catch (Exception $e) {
    // maybe something more graceful...
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}
// regular execution continues.

Upvotes: 2

Related Questions