Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/09/2014, 03:55
Avatar de madman_18
madman_18
 
Fecha de Ingreso: agosto-2010
Mensajes: 792
Antigüedad: 14 años, 6 meses
Puntos: 14
Respuesta: Uso de Api 4 de Facebook

Modificando un poco el ejemplo que he encontrado (por suerte...) en el doc de Facebook donde requiere el botón de iniciar sesión y demás me queda lo siguiente:
Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <title>Facebook Login JavaScript Example</title>
  3. <meta charset="UTF-8">
  4. </head>
  5.   // This is called with the results from from FB.getLoginStatus().
  6.   function statusChangeCallback(response) {
  7.     console.log('statusChangeCallback');
  8.     console.log(response);
  9.     // The response object is returned with a status field that lets the
  10.     // app know the current login status of the person.
  11.     // Full docs on the response object can be found in the documentation
  12.     // for FB.getLoginStatus().
  13.     if (response.status === 'connected') {
  14.       // Logged into your app and Facebook.
  15.       testAPI();
  16.     } else if (response.status === 'not_authorized') {
  17.       // The person is logged into Facebook, but not your app.
  18.       document.getElementById('status').innerHTML = 'Please log ' +
  19.         'into this app.';
  20.     } else {
  21.       // The person is not logged into Facebook, so we're not sure if
  22.       // they are logged into this app or not.
  23.       document.getElementById('status').innerHTML = 'Please log ' +
  24.         'into Facebook.';
  25.     }
  26.   }
  27.  
  28.   // This function is called when someone finishes with the Login
  29.   // Button.  See the onlogin handler attached to it in the sample
  30.   // code below.
  31.   function checkLoginState() {
  32.     FB.getLoginStatus(function(response) {
  33.       statusChangeCallback(response);
  34.     });
  35.   }
  36.  
  37.   window.fbAsyncInit = function() {
  38.   FB.init({
  39.     appId      : 'xxxxxxxxxxxxxx',
  40.     cookie     : true,  // enable cookies to allow the server to access
  41.                         // the session
  42.     xfbml      : true,  // parse social plugins on this page
  43.     version    : 'v2.1' // use version 2.1
  44.   });
  45.  
  46.   // Now that we've initialized the JavaScript SDK, we call
  47.   // FB.getLoginStatus().  This function gets the state of the
  48.   // person visiting this page and can return one of three states to
  49.   // the callback you provide.  They can be:
  50.   //
  51.   // 1. Logged into your app ('connected')
  52.   // 2. Logged into Facebook, but not your app ('not_authorized')
  53.   // 3. Not logged into Facebook and can't tell if they are logged into
  54.   //    your app or not.
  55.   //
  56.   // These three cases are handled in the callback function.
  57.  
  58.   FB.getLoginStatus(function(response) {
  59.     statusChangeCallback(response);
  60.   });
  61.  
  62.   };
  63.  
  64.   // Load the SDK asynchronously
  65.   (function(d, s, id) {
  66.     var js, fjs = d.getElementsByTagName(s)[0];
  67.     if (d.getElementById(id)) return;
  68.     js = d.createElement(s); js.id = id;
  69.     js.src = "//connect.facebook.net/en_US/sdk.js";
  70.     fjs.parentNode.insertBefore(js, fjs);
  71.   }(document, 'script', 'facebook-jssdk'));
  72.  
  73.   // Here we run a very simple test of the Graph API after login is
  74.   // successful.  See statusChangeCallback() for when this call is made.
  75.   function testAPI() {
  76.     console.log('Welcome!  Fetching your information.... ');
  77.     FB.api('/xxxxxxxxxx/ratings', function(response) {
  78.         if (response && response.error){
  79.            console.log("ERROR: "+response.error.message);
  80.         }else{
  81.             console.log("RESPUESTA: "+response.open_graph_story);
  82.         //console.log('Successful login for: ' + response.rating);
  83.         document.getElementById('status').innerHTML ='Thanks for logging in, ' + response.name + '!';
  84.         }
  85.     });
  86.    /* FB.api("/410442505719113/ratings",function(response){
  87.            if (response && !response.error){
  88.            console.log(response.name);
  89.            }else{
  90.             console.log("ERROR : "+response.error.message);
  91.            }
  92.         });*/
  93.   }
  94.  
  95.  
  96.  
  97.  
  98.  
  99. <!--
  100.  Below we include the Login Button social plugin. This button uses
  101.  the JavaScript SDK to present a graphical Login button that triggers
  102.  the FB.login() function when clicked.
  103. -->
  104.  
  105. <fb:login-button scope="public_profile,email" onlogin="checkLoginState();"></fb:login-button>
  106. <div id="status"></div>
  107.  
  108. </body>
  109. </html>

Pero en el error siempre me está sacando que no es una página...cuando sí lo es (el id es el número que aparece en la URL si no estoy equivocado) y no entiendo por qué :S :S :S :S :S

Ah y segundo...reparando ese problema...cómo se podría hacer para mostrarlo??????
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, te convertes en algo muy diferente"