2011-07-30 7 views
0

ユーザーがfacebookからチェックインするfacebookを通じてログインしていない場合は、このコードを使用します。ポストフェイスブックにリフレッシュせずに返信する方法

if($req_user['oauth_provider'] != "facebook") 
{ 
    <input type="checkbox" name="fb_post" id="fb_post" value="1" onclick="facebookPermissionsGrant(); return false;">} 
?> 

ユーザーがチェックFacebookのショーチェックボックスを介してログインしている場合:ユーザーはFacebookからログインしてchecboxをチェックし、Facebookを利用して、ユーザー名とパスワードを入力されていない場合、私が午前

if($req_user['oauth_provider'] == "facebook" && $CONFIG['fb_status'] == 1) { 
<input type="checkbox" name="fb_post" id="fb_post" value="1" checked> 
} 

問題があります。彼は、そのボックスがチェックされていることを確認するためにページを再びリフレッシュしなければならない ajaxやjqueryには方法がありますので、ページを更新する必要はありません。ユーザーがログインしている場合はチェックボックスが表示されますか?

答えて

0

はい、あります。 FacebookのJavascript APIにはFB.Event.Subscribeがあり、ユーザーのログイン状況が変わったときにJavaScriptを通知します。

例:

window.fbAsyncInit = function() { 
    FB.init({ 
     appId : 'YOURAPPID', 
     status : true, // check login status 
     cookie : true, // enable cookies to allow the server to access the session 
     xfbml : true, // parse XFBML 
     channelUrl : 'http://www.yourdomain.com/channel.html', // Custom Channel URL 
     oauth : true //enables OAuth 2.0 
    }); 

    // retrieve the login status. 
    FB.getLoginStatus(function(response) { 
     if (response.authResponse) update_user_is_connected(); 
     else update_user_is_not_connected(); 
    }); 

    // This will be triggered as soon as the user logs into Facebook (through your site) 
    FB.Event.subscribe('auth.login', function(response) { 
     update_user_is_connected(); 
    }); 
}; 

あなたがここにFB.Event.subscribe詳細を読むことができます:http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

関連する問題