facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.17k stars 1.95k forks source link

CURL not geting response from facebook #1230

Closed gautamsinh closed 3 years ago

gautamsinh commented 3 years ago

Hello There

we have strange issue using facebook php sdk,

we are using it since last 3 year everything work fine, but in few days we can not get response from CURL call of facebook.

`<?php

  try {
        $fb = new \Facebook\Facebook(['app_id' => 'myapid','app_secret' => 'mysecretekey','default_graph_version' => 'v6.0']);
        $helper = $fb->getRedirectLoginHelper();
  }catch(Exception $e){
  }

  if(isset($_GET['error']) && isset($_GET['error_code']) && isset($_GET['error_reason']) && isset($_GET['state'])){
  } elseif(isset($_GET['code'])){
         if(isset($_GET['state'])){
              $error = 0;
              try {
                $accessToken = $helper->getAccessToken();
              }catch(Facebook\Exceptions\FacebookResponseException $e) {
              }

              if(!isset($accessToken)){
                  if($helper->getError()){
                  }else {
                     $userData = $fb->get('/me?fields=id,name,first_name,last_name,email', $accessToken)->getGraphUser();
                     if (is_object($userData)) {
                     $userData = (array)$userData;
                     }
                  }
              }
         }
  }else{
  echo '<a href="'.$helper->getLoginUrl(BASE_URL."/login.php", ['email']).'">Facebook</a>';
  }

` When we press login button then there is no response if we call $accessToken = $helper->getAccessToken();

Its give timout error from CURL.

after doing some R&D we found this error because of CURL nnot getting response from server (Facebook),

but in on our server there many other CURL are called and its working properly. only Facebook is stopped working

If will good if you can support us fast because Facebook login is most important part of our product

gautamsinh commented 3 years ago

There is problem with SSL Handshake and CURL timout

I put this code in CURL call "CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,"

this is work for me