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

El siguiente código cambiando el ID de la aplicación casi funciona.

Ahora ya me sale el pop-up de facebook, sin embargo me da un error

API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.



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. <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
  8. <p id="fb_connect"><a href="#" id="login">Entrar con facebook</a></p>
  9. <div id="fb-root"></div>
  10. <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
  11. <script type="text/javascript">
  12.     FB.init({
  13.         appId: '1099xxxxx745209',
  14.         status: true,
  15.         cookie: true,
  16.         xfbml: true
  17.     });
  18.     $(document).ready(function(){
  19.         FB.getLoginStatus(function(response) {
  20.             if (response.session) {
  21.                 FB.api('/me', function (usuario) {
  22.                     $("#fb_connect").append('<span id="welcome">Bienvenido <strong>' + usuario.name + '</strong> | <a id="logout" href="#">Cerrar seción</a></span>');
  23.                     $("#login").hide();
  24.  
  25.                     $("#publish_entrie").load("templates/editor.html");
  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.Data.query('SELECT pic FROM user WHERE uid = me()').wait(function (filas) {
  39.                                 fb_pic = filas[0].pic;
  40.                                 $.post(
  41.                                     "fb-register.php",
  42.                                     {
  43.                                         idUser: usuario.id,
  44.                                         name: usuario.name,
  45.                                         link: usuario.link,
  46.                                         pic: fb_pic,
  47.                                         email: usuario.email,
  48.                                         website: usuario.website
  49.                                     }
  50.                                 );
  51.                             });
  52.                             $("#fb_connect").append('<span id="welcome">Bienvenido <strong>' + usuario.name + '</strong> | <a id="logout" href="#">Cerrar seción</a></span>');
  53.                             $("#login").hide();
  54.                             $("#publish_entrie").load("templates/editor.html");
  55.                         });
  56.                     }
  57.                 }
  58.             },
  59.             { perms: 'user_website, email' }
  60.         );
  61.     });
  62.     $('#logout').live("click", function(e){
  63.         FB.logout(function(){
  64.             $("#welcome").hide();
  65.             $("#login").show();
  66.             $("#publish_entrie").html("");
  67.             e.preventDefault();
  68.         });
  69.     });
  70. </body>
  71. </html>

Salu2!