Código HTML:
Ver original
<? session_start(); date_default_timezone_set('America/Santiago'); error_reporting(-1); ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="author" content=""> <link rel="shortcut icon" href="images/favicon.ico"> <link href="css/xxx.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="noFans" style="display:none"> ACA VA EL ME GUSTA </div> <div id="fans" style="display:block"> <ul> amigos(por mail o Facebook) </li> </ul> </div> <div id="Registro" style="display:none"> IMPORTANTE DEBES AUTORIZARNOS PARA PODER ENTRAR A ESTA APP!!!<br /> <br /> <br /> </div> <div id="phfriends"> </div> </div> <script> var udfbk=0; function statusChangeCallback(response) { if (response.status === 'connected') { udfbk=response.authResponse.userID; getPictureFriends(); who(); } else if (response.status === 'not_authorized') { fadeLogin(); } else { fadeLogin(); } } function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); }); } window.fbAsyncInit = function() { FB.init({ appId : 'XXXXXXXXXXXXX', cookie : true, xfbml : true, version : 'v2.0' }); FB.getLoginStatus(function(response) { console.log("Login Status Starting"); statusChangeCallback(response); }); var page_like_or_unlike_callback = function(url, html_element) { console.log('CALBACK STARTING!!!'); ifLike(); } FB.Event.subscribe('edge.create', page_like_or_unlike_callback); FB.Event.subscribe('edge.remove', page_like_or_unlike_callback); }; (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/es_CL/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function who() { console.log('Hola.... '); FB.api('/me', {fields: 'id, name, email, birthday'}, function(response) { console.log(response.id); console.log(response.name); console.log(response.email); console.log(response.birthday); $.ajax({ type: "POST", url: "registra_informacion_ing.php", data: { id: response.id, name: response.name, email: response.email, cumple: response.birthday } }).done(function( msg ) { }); ifLike(); }); } function verificar(){ FB.login(function(response) { statusChangeCallback(response); }, { scope: 'publish_stream, user_birthday, email, friends_photos, user_likes' }); } function ifLike(){ console.log('Te gusta o no?'); FB.api({ method: 'pages.isFan', page_id: 'MI PAGINA' }, function(resp) { if (resp) { console.log('SI!!!'); $("#fans").fadeIn(); } else { console.log('mmmmm!!!'); $("#Registro").fadeOut(); $("#fans").fadeOut(); $("#noFans").fadeIn(); } }); } function fadeLogin(){ $("#noFans").fadeOut(); $("#fans").fadeOut(); $("#Registro").fadeIn(); } function getFriends(){ FB.api('me/friends', {fields: 'name,id,picture', limit:80},function(response) { if(response.data) { var markup = ''; $.each(response.data,function(index,friend) { console.log(friend.picture.data.url); markup += '<img src="' + friend.picture.data.url + '"> '; }); $('#phfriends').prepend(markup); } else { $('#phfriends').prepend("FACEBOOK IMG"); } }); } </script> </body> </html>
Muchas Gracias