2012-03-27 201 views
0

我已經createn一個應用程序,這個程序可以發現hereFacebook應用授權

一切工作應該是除了當有人使用首次應用fromt。它產生的對話框,允許用戶看到我已請求何種類型或許可使用本 -

$url = $facebook->getLoginUrl(array(
'canvas' => 1, 
'req_perms' => 'publish_stream, email, offline_access', 
'fbconnect' => 0 
)); 

一旦用戶點擊確定他們然後重定向到我的應用程序坐在網址,而不是重定向到URL在Facebook內的應用程序。

其他的代碼,我有一個與該應用程序的工作原理 -

include_once("includes/src/facebook.php"); 
include_once("includes/src/facebook_config.php"); 
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID, 
'secret' => FACEBOOK_SECRET_KEY, 
'cookie' => false, 
'domain' => 'syncro-it.co.uk' 
)); 


<div id="fb-root"></div> 
     <script> 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId : '<?=FACEBOOK_APP_ID?>', 
      status : true, // check login status 
      cookie : true, // enable cookies to allow the server to access the session 
      xfbml : true // parse XFBML 
     }); 
     FB.Canvas.setSize(); 
     }; 

     (function() { 
     var e = document.createElement('script'); 
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
     e.async = true; 
     document.getElementById('fb-root').appendChild(e); 
     }()); 
     </script> 

有沒有人碰到這之前?如果是的話,我錯過了一些愚蠢的東西?

回答

1

的設置試試這個:

<? 
    // 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('facebook.php'); 

    $config = array(
    'appId' => '2XXXXXXXXXXXX36', 
    'secret' => 'XXXXXXXXXXXXXXXX43d18d86f157d', 
    'fileUpload' => true, 
); 

    $facebook = new Facebook($config); 
    $user_id = $facebook->getUser(); 
if($user_id) { 
    try { 
     $user_profile = $facebook->api('/me','GET'); 
       echo $user_profile['birthday']; 
        //---------------------------------- 
        //PUSH UR CODE HERE 
        //---------------------------------- 
    } 
catch(FacebookApiException $e) 
{ 
     $login_url = $facebook->getLoginUrl(array(
     'scope' => 'user_birthday' 
     )); 
echo "<script type='text/javascript'>top.location.href = '$login_url';</script>"; 
exit; 
} 
} 
else 
{ 
     $login_url = $facebook->getLoginUrl(array(
         'scope' => 'user_birthday' 
        )); 
    echo "<script type='text/javascript'>top.location.href = '$login_url';      </script>"; 
       exit; 
     } 
    ?> 
0

這是簡單地改回舊的權限對話框,應用