PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 7, 2022

[FIXED] Facebook PHP SDK: Unknown SSL protocol error

 January 07, 2022     facebook, facebook-graph-api, facebook-php-sdk, php, ssl     No comments   

Issue

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?


Solution

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


Answered By - hex7c0
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing