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

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


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;


why are you creating the exception on the try block?

my current working login function goes something like this:

public function login(){                   $this->load->library('facebook/facebook',$config);    $uid = $this->facebook->getUser();    if ($uid)     {                 try       {                     $user_profile = $this->facebook->api('/' . $uid);          //then redirect to whatever you need..      }       catch (FacebookApiException $e)       { error_log($e);        $uid = null;        $this->facebook->destroySession();      }    }    else     {        $params = array(            'canvas'    => 1,            'fbconnect' => 0,            'scope' => 'email',        );        echo "<script>top.location.href='" . $this->facebook->getLoginUrl($params)."'</script>";                    exit();    }}


I had the same problem like you.

I add this option before curl_exec() in base_facebook.php

curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);