title: Facebook SDK exception catch error but return null
body: <p>I am new on this field, so sorry for any mistake that I made</p>
  
  <p>I have create a website that using facebook login by facebook php sdk.
  I have tested on my localhost, it work fine, but when I upload to the real server on internet. It catch the facebook sdk exception, but the exception return null.
  I don't know how to check it, because on my wamp server everything work fine.</p>
  
  <p>This is my login code. </p>
  
  <pre><code>require_once __DIR__ . '/Facebook/autoload.php';        
  $fb = new Facebook\Facebook([
  'app_id' =&gt; '?',
  'app_secret' =&gt; '?',
  'default_graph_version' =&gt; 'v2.4',
  ]); 
  $helper = $fb-&gt;getRedirectLoginHelper();        
  $permissions = ['email','public_profile','user_likes']; // Optional permissions
  $loginUrl = $helper-&gt;getLoginUrl('http://example.com/logincallback.php', $permissions);
  echo '&lt;a href="' . htmlspecialchars($loginUrl) . '"&gt;&lt;img src="../images/system/fbround.png" width="50" height="50" /&gt;&lt;/a&gt;';
  </code></pre>
  
  <p>This is my redirect page.</p>
  
  <pre><code>include("config.php");
  require_once __DIR__. '/pages/Facebook/autoload.php';
  $fb = new Facebook\Facebook([
    'app_id' =&gt; '?',  
    'app_secret' =&gt; '?',  
    'default_graph_version' =&gt; 'v2.4',  
  ]);
  
  $helper = $fb-&gt;getRedirectLoginHelper();  
  
  try {  
    $accessToken = $helper-&gt;getAccessToken();  
  } catch(Facebook\Exceptions\FacebookResponseException $e) {  
    // When Graph returns an error  
    echo 'Graph returned an error: ' . $e-&gt;getMessage();  
    exit;  
  } 
  catch(Facebook\Exceptions\FacebookSDKException $e) {  
    // When validation fails or other local issues
    echo 'Facebook SDK returned an error: ' . $e-&gt;getMessage(); 
    exit;  
  }  
  
  if (! isset($accessToken)) {  
    if ($helper-&gt;getError()) {  
      header('HTTP/1.0 401 Unauthorized');  
      echo "Error: " . $helper-&gt;getError() . "\n";
      echo "Error Code: " . $helper-&gt;getErrorCode() . "\n";
      echo "Error Reason: " . $helper-&gt;getErrorReason() . "\n";
      echo "Error Description: " . $helper-&gt;getErrorDescription() . "\n";
    } else {  
      header('HTTP/1.0 400 Bad Request');  
      echo 'Bad request';  
    }  
    exit;  
  }
  
  // The OAuth 2.0 client handler helps us manage access tokens  
  $oAuth2Client = $fb-&gt;getOAuth2Client();  
  
  // Get the access token metadata from /debug_token  
  $tokenMetadata = $oAuth2Client-&gt;debugToken($accessToken);
  
  $response = $fb-&gt;get('/me?fields=id,name,email', $accessToken-&gt;getValue());
  
  $user = $response-&gt;getGraphUser();
  
  
  
  $_SESSION['user_fbid']=$user['id'];
  $_SESSION['user_email']=$user['email'];
  $_SESSION['user_fullname']=$user['name'];
  $_SESSION['accesstoken']=(string) $accessToken;
  $_SESSION['facebooklogin']='1';
  
  // Validation (these will throw FacebookSDKException's when they fail)  
  $tokenMetadata-&gt;validateAppId('1501129246877759');  
  // If you know the user ID this access token belongs to, you can validate it here  
  // $tokenMetadata-&gt;validateUserId('123');  
  $tokenMetadata-&gt;validateExpiration();   
  
  if (! $accessToken-&gt;isLongLived()) {  
  // Exchanges a short-lived access token for a long-lived one  
  try {  
    $accessToken = $oAuth2Client-&gt;getLongLivedAccessToken($accessToken);  
  } catch (Facebook\Exceptions\FacebookSDKException $e) {  
    echo "&lt;p&gt;Error getting long-lived access token: " . $helper-&gt;getMessage() . "&lt;/p&gt;";  
    exit;  
  } 
    echo '&lt;h3&gt;Long-lived&lt;/h3&gt;';  
    var_dump($accessToken-&gt;getValue());  
  }
  
  header('Location: http://example.com');
  </code></pre>
  
  <p>I got this code for documentation on facebook app.
  I have enable php_curl extension and php_mbstring extension on my online server
  but it always return exception error with the description.</p>
  
  <p>this is the error:</p>
  
  <pre><code>Facebook SDK returned an error: 
  </code></pre>
  
  <p>I don't now why it doesn't work on my online server. but it work perfectly on my wamp server.</p>
  
  <p>This is the exception that have been catch</p>
  
  <pre><code>object(Facebook\Exceptions\FacebookSDKException)#14 (7) { ["message":protected]=&gt; string(0) "" ["string":"Exception":private]=&gt; string(0) "" ["code":protected]=&gt; int(7) ["file":protected]=&gt; string(74) "/home/www/yeaksa.com/pages/Facebook/HttpClients/FacebookCurlHttpClient.php" ["line":protected]=&gt; int(83) ["trace":"Exception":private]=&gt; array(6) { [0]=&gt; array(6) { ["file"]=&gt; string(54) "/home/www/yeaksa.com/pages/Facebook/FacebookClient.php" ["line"]=&gt; int(216) ["function"]=&gt; string(4) "send" ["class"]=&gt; string(43) "Facebook\HttpClients\FacebookCurlHttpClient" ["type"]=&gt; string(2) "-&gt;" ["args"]=&gt; array(5) { [0]=&gt; string(1029) "https://graph.facebook.com/v2.4/oauth/access_token?code=AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu&amp;redirect_uri=http%3A%2F%2Fyeaksa.com%2Flogincallback.php%3Fcode%3DAQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu&amp;client_id=171845566490390&amp;client_secret=444cd426e0262bcf9c5c0c8fe34b4e7a&amp;access_token=171845566490390%7C444cd426e0262bcf9c5c0c8fe34b4e7a&amp;appsecret_proof=fcac56612f51e2c41a4b07c2f7746035c7dfe29e2542225b8a804ae33845aa62" [1]=&gt; string(3) "GET" [2]=&gt; string(0) "" [3]=&gt; array(3) { ["Content-Type"]=&gt; string(33) "application/x-www-form-urlencoded" ["User-Agent"]=&gt; string(12) "fb-php-5.0.0" ["Accept-Encoding"]=&gt; string(1) "*" } [4]=&gt; int(60) } } [1]=&gt; array(6) { ["file"]=&gt; string(67) "/home/www/yeaksa.com/pages/Facebook/Authentication/OAuth2Client.php" ["line"]=&gt; int(277) ["function"]=&gt; string(11) "sendRequest" ["class"]=&gt; string(23) "Facebook\FacebookClient" ["type"]=&gt; string(2) "-&gt;" ["args"]=&gt; array(1) { [0]=&gt; object(Facebook\FacebookRequest)#13 (9) { ["app":protected]=&gt; object(Facebook\FacebookApp)#3 (2) { ["id":protected]=&gt; string(15) "171845566490390" ["secret":protected]=&gt; string(32) "444cd426e0262bcf9c5c0c8fe34b4e7a" } ["accessToken":protected]=&gt; string(48) "171845566490390|444cd426e0262bcf9c5c0c8fe34b4e7a" ["method":protected]=&gt; string(3) "GET" ["endpoint":protected]=&gt; string(19) "/oauth/access_token" ["headers":protected]=&gt; array(1) { ["Content-Type"]=&gt; string(33) "application/x-www-form-urlencoded" } ["params":protected]=&gt; array(4) { ["code"]=&gt; string(344) "AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" ["redirect_uri"]=&gt; string(385) "http://yeaksa.com/logincallback.php?code=AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" ["client_id"]=&gt; string(15) "171845566490390" ["client_secret"]=&gt; string(32) "444cd426e0262bcf9c5c0c8fe34b4e7a" } ["files":protected]=&gt; array(0) { } ["eTag":protected]=&gt; NULL ["graphVersion":protected]=&gt; string(4) "v2.4" } } } [2]=&gt; array(6) { ["file"]=&gt; string(67) "/home/www/yeaksa.com/pages/Facebook/Authentication/OAuth2Client.php" ["line"]=&gt; int(226) ["function"]=&gt; string(27) "sendRequestWithClientParams" ["class"]=&gt; string(36) "Facebook\Authentication\OAuth2Client" ["type"]=&gt; string(2) "-&gt;" ["args"]=&gt; array(2) { [0]=&gt; string(19) "/oauth/access_token" [1]=&gt; array(2) { ["code"]=&gt; string(344) "AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" ["redirect_uri"]=&gt; string(385) "http://yeaksa.com/logincallback.php?code=AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" } } } [3]=&gt; array(6) { ["file"]=&gt; string(67) "/home/www/yeaksa.com/pages/Facebook/Authentication/OAuth2Client.php" ["line"]=&gt; int(166) ["function"]=&gt; string(20) "requestAnAccessToken" ["class"]=&gt; string(36) "Facebook\Authentication\OAuth2Client" ["type"]=&gt; string(2) "-&gt;" ["args"]=&gt; array(1) { [0]=&gt; array(2) { ["code"]=&gt; string(344) "AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" ["redirect_uri"]=&gt; string(385) "http://yeaksa.com/logincallback.php?code=AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" } } } [4]=&gt; array(6) { ["file"]=&gt; string(75) "/home/www/yeaksa.com/pages/Facebook/Helpers/FacebookRedirectLoginHelper.php" ["line"]=&gt; int(255) ["function"]=&gt; string(22) "getAccessTokenFromCode" ["class"]=&gt; string(36) "Facebook\Authentication\OAuth2Client" ["type"]=&gt; string(2) "-&gt;" ["args"]=&gt; array(2) { [0]=&gt; string(344) "AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" [1]=&gt; string(385) "http://yeaksa.com/logincallback.php?code=AQA1pHyXLTD8BIkpNG8gd60h0kI2I0uJpKS5KOtwSZPU0Ak1H_a0_cXaORNasnKmXRHTSqBngUGepiTEwmPMvHsbGRku53SXI6t0oPXIjMdR8JAwPyuozltmaKfg_UZ6zeCVJrnPDsoBvFoznY4tQqSUQw-81fbvUui9kSVhJQhtRIlUrNE4vhd23EPNv0454enY4H3K2waGFtcg4qolyAGLOXqn6szOJj2HHZkUkqlvqaBchkvu55154aX5sp35cENjLgWcTFgRiGSHzcH20nQX_EOoHq5D5q6VCsT1OAFSq0DCIk3_nxDFvP1vl4T1kq99SegDVe-OPhBIAOLyMcxu" } } [5]=&gt; array(6) { ["file"]=&gt; string(38) "/home/www/yeaksa.com/logincallback.php" ["line"]=&gt; int(15) ["function"]=&gt; string(14) "getAccessToken" ["class"]=&gt; string(44) "Facebook\Helpers\FacebookRedirectLoginHelper" ["type"]=&gt; string(2) "-&gt;" ["args"]=&gt; array(0) { } } } ["previous":"Exception":private]=&gt; NULL }
  </code></pre>
  
  <p>Please help me. Thanks in advance.</p>