Código PHP:
Ver original
<?php // uses the PHP SDK. Download from https://github.com/facebook/php-sdk include("src/facebook.php"); // // from the facebook app page // // new facebook object to interact with facebook 'appId' => YOUR_APP_ID, 'secret' => YOUR_APP_SECRET, )); // // if user is logged in on facebook and already gave permissions // to your app, get his data: $userId = $facebook->getUser(); ?> <html> <head> <style>body { text-align:center; font-size: 40px }</style> </head> <body> <?php if ($userId) { // // already logged? show some data $user_profile = $facebook->api('/' + $userId); //*** Este es el formulario que se reenvia constantemente ***// echo "<p>YOU ARE: <strong>". $user_profile['name'] ."</strong><br/>"; echo "Your birth date is: ".$user_profile['birthday']."</p>"; echo '<form name="check_out_form" id="idFormulario" action="valida.php" method="post"> <input type="hidden" name="id" value="'.$user_profile["id"].'"> <input type="hidden" name="name" value="'.$user_profile["name"].'"> <input type="hidden" name="first_name" value="'.$user_profile["first_name"].'"> <input type="hidden" name="middle_name" value="'.$user_profile["middle_name"].'"> <input type="hidden" name="last_name" value="'.$user_profile["last_name"].'"> <input type="hidden" name="link" value="'.$user_profile["link"].'"> <input type="hidden" name="username" value="'.$user_profile["username"].'"> <input type="hidden" name="location" value="'.$user_profile["location"]["name"].'"> <input type="hidden" name="gender" value="'.$user_profile["gender"].'"> <input type="hidden" name="email" value="'.$user_profile["email"].'"> <script language="JavaScript"> document.getElementById("idFormulario").submit(); </script> </form>'; } else { // // use javaascript api to open dialogue and perform // the facebook connect process by inserting the fb:login-button ?> <div id="fb-root"></div> <fb:login-button scope='email'></fb:login-button> <?php } ?> <script> window.fbAsyncInit = function() { FB.init({ appId : <?=YOUR_APP_ID?>, status : true, cookie : true, xfbml : true, oauth : true, }); FB.Event.subscribe('auth.login', function(response) { // ------------------------------------------------------ // This is the callback if everything is ok window.location.reload(); }); }; (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/es_ES/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); </script> </body> </html>