title: Facebook Error: An error occurred with app. Please try again later
body: <p>My code which was working until yesterday, all of a sudden has started throwing errors. No clue what changed et all. It is also based on code from <a href="https://developers.facebook.com/docs/authentication/server-side/" rel="nofollow">Facebook Serve side authentication</a> Also I referred to others posts with the similar title but tried what they mention with not much luck.</p>
  
  <p>Here is the code </p>
  
  <pre><code>&lt;?php 
  
     $app_id = "my app id";
     $app_secret = "my app secret";
     $my_url = "http://apps.facebook.com/myappnamespace";
  </code></pre>
  
  <p>//Tried with https in my_url
  //Also tried with the direct path to the app both with http and https and does not work as well.
         session_start();
         $code = $_REQUEST["code"];</p>
  
  <pre><code>   if(empty($code)) {
       $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
       $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
         . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;state="
         . $_SESSION['state'];
  
       echo("&lt;script&gt; top.location.href='" . $dialog_url . "'&lt;/script&gt;");
     }
  
     if($_REQUEST['state'] == $_SESSION['state']) {
       $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;
  
       $response = file_get_contents($token_url);
       $params = null;
       parse_str($response, $params);
  
       $graph_url = "https://graph.facebook.com/me?access_token=" 
         . $params['access_token'];
  
       $user = json_decode(file_get_contents($graph_url));
       echo("Hello " . $user-&gt;name);
     }
     else {
       echo("The state does not match. You may be a victim of CSRF.");
     }
  
   ?&gt;
  </code></pre>