Ver Mensaje Individual
  #12 (permalink)  
Antiguo 06/12/2010, 05:08
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 2 meses
Puntos: 20
Respuesta: Loguear con facebook

Buenas danneg,

Antes de nada darte las gracias por tu aporte!

Pero no consigo hacerlo funcionar! creo que me faltan cosas no? simplemente tengo un archivo index.php con la siguiente información

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <title>Prueba Facebook Connect</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  6. </head>
  7. <a href="#" id="login">Entrar con facebook</a>
  8. <div id="fb-root"></div>
  9. <script type="text/javascript" src="http://connect.facebook.net/es_ES/all.js"></script>
  10. <script type="text/javascript">
  11.     var nombre;
  12.     var link;
  13.     var imagen;
  14.     FB.init({
  15.         appId: '10991XXXXX5209',
  16.         status: true,
  17.         cookie: true,
  18.         xfbml: true
  19.     });
  20.     $(document).ready(function(){
  21.         FB.getLoginStatus(function(response) {
  22.             if (response.session) {
  23.                 FB.api('/me', function (usuario) {
  24.                     $("#fb_connect").append('<span id="welcome">Bienvenido <strong>' + usuario.name + '</strong> | <a id="logout" href="#">Cerrar seción</a></span>');
  25.                     $("#login").hide();
  26.                 });
  27.             }
  28.         });
  29.     });
  30.     $('#login').click(function (e) {
  31.         e.preventDefault();
  32.         FB.login(
  33.             function(response) {
  34.                 if (response.session) {
  35.                     if (response.perms) {
  36.                         FB.api('/me', function (usuario) {
  37.                             var fb_pic;
  38.                             FB.api(
  39.                                 {
  40.                                     method: 'fql.query',
  41.                                     query: 'SELECT pic FROM user WHERE uid=5526183'
  42.                                 },
  43.                                 function(response) {
  44.                                     fb_pic = response[0].pic;
  45.                                 }
  46.                             );
  47.                             $.post(
  48.                                 "fb-register.php",
  49.                                 {
  50.                                     idUser: usuario.id,
  51.                                     name: usuario.name,
  52.                                     link: usuario.link,
  53.                                     pic: fb_pic,
  54.                                     email: usuario.email,
  55.                                     website: usuario.user_website
  56.                                 }
  57.                                             $("#login").hide();
  58.                         });
  59.                     }
  60.                 }
  61.             },
  62.             { perms: 'user_website, email' }
  63.         );
  64.     });
  65.     $('#logout').live("click", function(e){
  66.         FB.logout(function(){
  67.             $("#welcome").hide();
  68.             $("#login").show();
  69.             e.preventDefault();
  70.         });
  71.     });
  72. <h1>Prueba con Facebook Connect </h1>
  73.  
  74. </body>
  75. </html>

No hay que cargar alguna librería de facebook, o algún otro archivo? si ejecutas este código no hace nada, el botón de Entrar con facebook no hace nada :S

Muchas gracias de antemano!