Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/04/2014, 21:08
diwcexd
 
Fecha de Ingreso: noviembre-2013
Ubicación: Tangamandapio
Mensajes: 13
Antigüedad: 10 años, 5 meses
Puntos: 1
Respuesta: Facebook Connect en mi sitio web

Bueno, alfin logre hallar una solucion, aki les dejo para el que esté en una similar situación mi pagina para que se guien y le cambien de acuerdo a Uds. :

Código PHP:
<?php
    
// Remember to copy files from the SDK's src/ directory to a
    // directory in your application on the server, such as php-sdk/
      
require_once('includes/facebook.php');

      
$config = array(
        
'appId' => 'APPD ID AKI',
        
'secret' => 'SECRET AKI',
        
'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
      
);

      
$facebook = new Facebook($config);
      
$user_id $facebook->getUser();
    
    
?>

<!-- Visualización de datos del Usuario en el "Topbar" -->

  <?php
    
if($user_id) {

      
// We have a user ID, so probably a logged in user.
      // If not, we'll get an exception, which we handle below.
      
try {
        
        
$user_profile $facebook->api('/me','GET');
        
$logout_url $facebook->getLogoutUrl();
        
?>
        
        <div class="left">
            <img src="https://graph.facebook.com/<?php echo $user_profile['username']; ?>/picture" width="40" height="40" />
        </div>
        
        <div class="right">
            <center>
            <div class="top-bar-session-name"><?php echo $user_profile['name']; ?></div>
            <div class="top-bar-session-span">
                <a href="#" class="top-bar-session-panel">Panel</a>-<a href="<?php echo $logout_url ?>" class="top-bar-session-salir">Sal&iacute;r</a>
            </div>
            </center>
        </div>
        <?php echo ''?>

        <?php

      
} catch(FacebookApiException $e) {
        
// If the user is logged out, you can have a 
        // user ID even though the access token is invalid.
        // In this case, we'll get an exception, so we'll
        // just ask the user to login again here.
        
$login_url $facebook->getLoginUrl(); 
        echo 
'<a href="' $login_url '" class="top-bar-session-panel-iniciarsesion">Iniciar sesi&oacute;n</a>';
        
error_log($e->getType());
        
error_log($e->getMessage());
        
      }   
    } else {

      
// No user, print a link for the user to login
      
$login_url $facebook->getLoginUrl();
      echo 
'<a href="' $login_url '" class="top-bar-session-panel-iniciarsesion">Iniciar sesi&oacute;n</a>';

    }

  
?>

<div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId: '<?php echo $facebook->getAppID() ?>',
          cookie: true,
          xfbml: true,
          oauth: true
        });
        FB.Event.subscribe('auth.login', function(response) {
          window.location.reload();
        });
        FB.Event.subscribe('auth.logout', function(response) {
          window.location.reload();
        });
      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>