title: How to include Facebook login in my website?
body: <p>im trying to import "log in with facebook" opportunity to my website, im using <a href="http://developers.facebook.com/docs/authentication" rel="nofollow">http://developers.facebook.com/docs/authentication</a>, but still can not make it work.
  I register my website and have app id and app secret.
  I have the following code in my login form:</p>
  
  <pre><code> &lt;a href="facebook.php"&gt;&lt;img src="images/fb-login-button.png" /&gt;&lt;/a&gt;
  </code></pre>
  
  <p>facebook.php file:</p>
  
  <pre><code>&lt;?php 
  
  $app_id = 1000000000000;
  $app_secret = "asdasdasdasd";
  $my_url = "http://xxxx.xx/";
  
  $code = $_REQUEST["code"];
  
  if(empty($code)) {
      $dialog_url = "http://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;");
  }
  
  $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);
  
  $graph_url = "https://graph.facebook.com/me?" . $access_token;
  
  $user = json_decode(file_get_contents($graph_url));
  
  echo("Hello " . $user-&gt;name);
  ?&gt;
  </code></pre>
  
  <p>It returns message "undefined index code" and I have no idea where and what to change.</p>
  
  <p>Please, help!</p>