Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Uncaught CurlException: 7: couldn't connect to host thrown in ....src/base_facebook.php on line 887

I'm trying to develop a sample facebook php login example following the example here

I've hosted my app here, but I'm getting the error message in the question whenever I try to access the link. Here's the code segment that throws the error

try {
  $e = new FacebookApiException(array(// LINE 887
             'error_code' => curl_errno($ch),
             'error' => array(
             'message' => curl_error($ch),
             'type' => 'CurlException',
        ),
  ));
  curl_close($ch);
}

// edit suggested by Kneel-before ZOD
catch(FacebookApiException $e) {
  $result = $e->getResult();
  echo 'Got an : ', $e->getType(),' while posting';
  echo(json_encode($result));
}

catch(Exception $e){
  echo 'Caught exception: ',  $e->getMessage(), "\n";
}

Im quite sure Ive setup the APP ID and secret correctly in index.php.

Here's a screenshot of my app setup on facebookApp setup

Any help would be appreciated. Thanks!

like image 689
seeker Avatar asked Sep 18 '13 06:09

seeker


1 Answers

You may need to give curl a certificate file for Facebook which you do like this:

Download the certificate files from https://github.com/facebookarchive/facebook-php-sdk/blob/master/src/fb_ca_chain_bundle.crt

and add this before attempting any Facebook calls

facebook::$CURL_OPTS[CURLOPT_CAINFO] = 'path/to/fb_ca_chain_bundle.crt';

You could also try

facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
like image 76
Hugh Wormington Avatar answered Oct 24 '22 09:10

Hugh Wormington