0

アプリケーションで「Facebookでログイン」を使用しています。「Facebookでログイン」ボタンを押した後、ホームページにリダイレクトしたい。実装方法がわかりません...

コードは、

    <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : 'APP ID', // App ID
        channelUrl : 'http://www.***.com/', // Channel File
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
      });

    // Load the SDK Asynchronously
    (function(d){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "js/all.js";
       ref.parentNode.insertBefore(js, ref);
     }(document));
  </script>


<div id="fb-root"></div>
   <div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1"></div>

助けてください、

ありがとう

4

2 に答える 2

1

Facebook イベントを使用する:

FB.Event.subscribe('auth.login', function(){
    window.location = 'index.html';
});

新しいコード:

<script>
window.fbAsyncInit = function() {
  FB.init({
    appId      : 'APP ID', // App ID
    channelUrl : 'http://www.***.com/', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
  });

FB.Event.subscribe('auth.login', function(){
    window.location.href = 'index.html';
});

// Load the SDK Asynchronously
(function(d){
   var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
   if (d.getElementById(id)) {return;}
   js = d.createElement('script'); js.id = id; js.async = true;
   js.src = "js/all.js";
   ref.parentNode.insertBefore(js, ref);
 }(document));
</script>

index.htmlあなたのホームページのURLに変更してください。

あなたも追加したい場合logout

FB.Event.subscribe('auth.logout', function(){
    window.location.href = 'index.html';
});
于 2012-09-21T09:01:12.643 に答える