1
votes

I have a PHP script who make "get" requests to the Facebook API Graph with the Facebook SDK for PHP.

For a few days, my script fails (50% of the time, or more), I've got this error:

Unknown SSL protocol error in connection to graph.facebook.com:443

and I don't know why because:

  • I didn't modify the script.
  • I didn't change anything on the server.
  • Moreover, my script runs on 2 servers and the problem occurs on both.

Here are the details:

#0 /var/www/oie/vendor/facebook/php-sdk-v4/src/Facebook/FacebookClient.php(216): Facebook\HttpClients\FacebookCurlHttpClient->send('https://graph.f...', 'GET', '', Array, 60) #1 /var/www/oie/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php(469): Facebook\FacebookClient->sendRequest(Object(Facebook\FacebookRequest)) #2 /var/www/oie/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php(342): Facebook\Facebook->sendRequest('GET', '273607869342343...', Array, NULL, NULL, NULL) #3 /var/www/oie/src/AppBundle/Controller/APIGraphController.php(239): Facebook\Facebook->get('273607869342343...') #4 [internal function]: AppBundle\Controller\APIGraphController->importAction(Object(Symfony\Component\HttpFoundation\Request)) #5 /var/www/oie/var/bootstrap.php.cache(3042): call_user_func_array(Array, Array) #6 /var/www/oie/var/bootstrap.php.cache(2997): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #7 /var/www/oie/var/bootstrap.php.cache(2337): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #8 /var/www/oie/web/app.php(18): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #9 {main}

What is the problem?

1

1 Answers

1
votes

I've same problem (SSL protocol error) with https://packagist.org/packages/facebook/graph-sdk#4.0.23

https://packagist.org/packages/facebook/php-sdk-v4 is abandoned FYI

the problems is with SSL certificate and cURL negotiation

I have solved with this change

inside vendor/facebook/graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php or vendor/facebook/php-sdk-v4/src/Facebook/HttpClients/FacebookCurlHttpClient.php

search public function openConnection function and inside options array add

  • CURLOPT_SSLVERSION => 6

and change

  • CURLOPT_SSL_VERIFYPEER => false