2011-09-25 17 views
0

は、私は簡単な使用して、アプリケーションのFacebookタブを認可するFB.uiを使用していますページタブにFB.uiに設定されていません:OAuth 2.0のクッキーが

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 
    channelUrl : 'http://<%= request.host_with_port %>/channel.html', // Custom Channel URL 
    oauth : true //enables OAuth 2.0 
}); 

FB.ui({ 
    method: 'oauth' 
    }, 
    function(response) { 
    // do some redirect stuff here 
}); 

認可罰金になりますが、ユーザーがアプリケーションを確認した場合でも、関連するfbsr_xxxxx Cookieが設定されていません。それを強制する方法はありますか?レスポンスオブジェクトにはuser_idが含まれていますが、signed_requestで標準フローを使用します。

答えて

0

私はまったく同じ問題を抱えています。新しいウィンドウを開くFB.login以外の方法で、ページを更新せずにアクセストークンを取得する方法はないようです。

FB.ui({ 
    method: 'oauth' 
    }, 
    function(response) { 
    if(response.session){ 
$.get('return_token.php', function(response){ 
var access_token = response; 
alert(access_token); 
}) 
} 
}); 




return_token.php: 

<? 
    $config = array(
    'appId' => $app_id, 
    'secret' => $secret 
); 

    $facebook = new Facebook($config); 

    try {$access_token = $facebook->getAccessToken();}catch(FacebookApiException $e) { 

     $result = $e->getResult(); 
     echo json_encode($result); 

    } 

echo $access_token; 

?> 
:あなたがやりたいことは何

はFB.ui応答の後にアクセストークンを返すために別のページへのAJAX呼び出しを行うことです