Facebook PHP SDK: Unknown SSL protocol error

我与影子孤独终老i 提交于 2020-01-24 21:51:12

问题


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:


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


来源:https://stackoverflow.com/questions/39466539/facebook-php-sdk-unknown-ssl-protocol-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!