2012-05-09 73 views
1

後,我登錄使用Facebook Connect,我需要用戶重定向到特定URL.The下面的代碼在firebox.but不chrome.please幫我Facebook連接不使用Chrome

<script type="text/JavaScript"> 
      FB.init({ 
       appId: '366168323431073', cookie: true, 
       status: true, xfbml: true 
      }); 
      FB.Event.subscribe('auth.login', function() { 
       window.top.location = "http://www.domain.com"; 
      }); 
     </script> 

回答

0

變化重定向URI在您的應用程序

<?php 

// Requires Facebook PHP SDK 3.0.1: https://github.com/facebook/php-sdk/ 
require ('facebook.php'); 

define('FACEBOOK_APP_ID',"YOUR-APP-ID-HERE"); 
define('FACEBOOK_SECRET',"YOUR-APP-API-SECRET-HERE"); 
define('REDIRECT_URI',"YOUR-REDIRECT-URL-HERE"); 
$user = null; 

$facebook = new Facebook(array(
    'appId' => FACEBOOK_APP_ID, 
    'secret' => FACEBOOK_SECRET, 
    'cookie' => true 
)); 

$user = $facebook->getUser(); // Get the UID of the connected user, or 0 if the Facebook user is not connected. 

if($user == 0) { 
    // If the user is not connected to your application, redirect the user to authentication page 
    /** 
    * Get a Login URL for use with redirects. By default, full page redirect is 
    * assumed. If you are using the generated URL with a window.open() call in 
    * JavaScript, you can pass in display=popup as part of the $params. 
    * 
    * The parameters: 
    * - redirect_uri: the url to go to after a successful login 
    * - scope: comma separated list of requested extended perms 
    */ 

    $login_url = $facebook->getLoginUrl($params = array('redirect_uri' => REDIRECT_URI)); 

    echo ("<script> top.location.href='".$login_url."'</script>"); 

} else { 
    // if the user is already connected, then redirect them to landing page or show some content 
    echo ("<script> window.location.href='".REDIRECT_URI."'</script>"); 
} 

?>