title: Facebook SDK error during login attempt: No URL set
body: <p>I'm getting the following error message</p>
  
  <blockquote>
    <p>Facebook SDK returned an error: No URL set! </p>
    
    <p>Fatal error:  Uncaught
    exception 'Facebook\Exceptions\FacebookSDKException' with message 'No
    URL set!' in
    /membri/csslab/sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php:83</p>
    
    <p>Stack trace: </p>
    
    <p>0 /membri/csslab/sdk/src/Facebook/FacebookClient.php(216): Facebook\HttpClients\FacebookCurlHttpClient->send('<a href="https://graph.f" rel="noreferrer">https://graph.f</a>...',
    'GET', '', Array, 60)</p>
    
    <p>1 /membri/csslab/sdk/src/Facebook/Authentication/OAuth2Client.php(277):
    Facebook\FacebookClient->sendRequest(Object(Facebook\FacebookRequest))</p>
    
    <p>2 /membri/csslab/sdk/src/Facebook/Authentication/OAuth2Client.php(226):
    Facebook\Authentication\OAuth2Client->sendRequestWithClientParams('/oauth/access_t...',
    Array)</p>
    
    <p>3 /membri/csslab/sdk/src/Facebook/Authentication/OAuth2Client.php(166):
    Facebook\Authentication\OAuth2Client->requestAnAccessToken(Array)</p>
    
    <p>4 /membri/csslab/sdk/src/Facebook/Helpers/FacebookRedirectLoginHelper.php(255):
    Facebook\Authentication\OAuth2Client->getAccessTokenFromCode('AQAAf_xMnFr0C7i...',
    '<a href="http://csslab.a" rel="noreferrer">http://csslab.a</a>...') </p>
    
    <p>5 /membri/csslab/login-callback.php(30):
    Facebook\Hel in
    /membri/csslab/sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php
    on line 83</p>
  </blockquote>
  
  <p>when trying to login with Facebook credentials. </p>
  
  <p>Everything works fine in local. I have properly set the domain in Facebook App.</p>
  
  <p>The code I'm using is that suggested by Facebook's documentation:</p>
  
  <pre><code>&lt;?php // login-callback.php
  session_start();
  
  function redirect($url, $permanent = false) {
      if (headers_sent() === false) {
          header('Location: ' . $url, true, ($permanent === true) ? 301 : 302);
      }
      exit();
  }
  
  $path = '';
  $uri = 'http://xxxxx.altervista.org';
  require_once $path . 'sdk/src/Facebook/autoload.php';
  
  $fb = new Facebook\Facebook([
      'app_id' =&gt; 'xxxxxxxxxxx',
      'app_secret' =&gt; 'xxxxxxxxxxxxxxxxxxxxxx',
      'default_graph_version' =&gt; 'v2.5',
      ]);
  
  $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)) {
      // Logged in!
      $_SESSION['facebook_access_token'] = (string) $accessToken;
  
      // Now you can redirect to another page and use the
      // access token from $_SESSION['facebook_access_token']
      redirect($uri . 'survey.php?token='.$_SESSION['facebook_access_token'] ,   false);
  } elseif ($helper-&gt;getError()) {
      // There was an error (user probably rejected the request)
      echo '&lt;p&gt;Error: ' . $helper-&gt;getError();
      echo '&lt;p&gt;Code: ' . $helper-&gt;getErrorCode();
      echo '&lt;p&gt;Reason: ' . $helper-&gt;getErrorReason();
      echo '&lt;p&gt;Description: ' . $helper-&gt;getErrorDescription();
      exit;
  }
  ?&gt;
  </code></pre>
  
  <p>UPDATE:</p>
  
  <pre><code> public function send($url, $method, $body, array $headers, $timeOut)
  {
  $this-&gt;openConnection($url, $method, $body, $headers, $timeOut);
  $this-&gt;sendRequest();
  
  if ($curlErrorCode = $this-&gt;facebookCurl-&gt;errno()) {
      throw new FacebookSDKException($this-&gt;facebookCurl-&gt;error(), $curlErrorCode);
  }
  
  // Separate the raw headers from the raw body
  list($rawHeaders, $rawBody) = $this-&gt;extractResponseHeadersAndBody();
  
  $this-&gt;closeConnection();
  
  return new GraphRawResponse($rawHeaders, $rawBody);
  }
  </code></pre>