Facebookが自動化されたときに、関数を呼び出すにはどうすればよいですか?成功に基づいて別のページに渡す必要があります。許可されている場合は、新しいjspに転送します。その関数を呼び出すにはどうすればよいですか?私はFb.uiを通してコールバック関数を書くかもしれないことを読みました。しかし、FB.uiはどのように呼び出されますか?試しましたが、FB.uiを呼び出す方法は?
1 に答える
            0        
        
		
FB.init の後にイベント リスナーを追加します。
<div id="fb-root"></div>
<script>
  FB.init({
      appId      : 'YOUR_APP_ID', // App ID from the App Dashboard
      channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
      status     : true, // check the login status upon init?
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : true  // parse XFBML tags on this page?
    });
  FB.Event.subscribe('auth.login', function(response) {
      alert('The status of the session is: ' + response.status);
      window.location.replace('http://www.NEW_URL.COM/');
  });
});
渡される応答オブジェクトには次が含まれます。
{
  status: "",         /* Current status of the session */
  authResponse: {          /* Information about the current session */
    userID: ""          /* String representing the current user's ID */
    signedRequest: "",  /* String with the current signedRequest */
    expiresIn: "",      /* UNIX time when the session expires */
    accessToken: "",    /* Access token of the user */
  }
}
要件に応じて、他の認証関連のイベントをリッスンできます。イベントのサブスクライブについては、http: //developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/の Facebook 開発者ドキュメントを参照してください。
于 2013-02-25T19:56:29.507   に答える