title: Facebook API 400 Bad Request
body: <p>I'm trying to use the Facebook api to run an fql query. I set everything up in PHP here is how the code looks:</p>
  
  <pre><code>  $app_id = 'APP_ID';
    $app_secret = 'APP_secret';
    $my_url = "url.com/facebook.php";
  
  
    $code = $_REQUEST["code"];
  
   //auth user
   if(empty($code)) {
      $dialog_url = 'https://www.facebook.com/dialog/oauth?client_id=' 
      . $app_id . '&amp;redirect_uri=' . urlencode($my_url) ;
      echo("&lt;script&gt;top.location.href='" . $dialog_url . "'&lt;/script&gt;");
    }
  
    //get user access_token
    $token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
      . $app_id . '&amp;redirect_uri=' . urlencode($my_url) 
      . '&amp;client_secret=' . $app_secret 
      . '&amp;code=' . $code;
    $access_token = file_get_contents($token_url);
  
  
    // Run fql query
    $fql_query_url = 'FQL_Query';
    $fql_query_result = file_get_contents($fql_query_url);
    $fql_query_obj = json_decode($fql_query_result, true);
  </code></pre>
  
  <p>Everything worked fine using the code above, but recently I decided to change my URL structure and instead of accessing the page via <strong>url.com/facebook.php</strong> I would like to access it via <strong>url.com/#facebook</strong>. </p>
  
  <p>When I made this change to the $my_url variable I received the following errors. </p>
  
  <pre><code>[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
  </code></pre>
  
  <p>Any ideas? Thanks!</p>