当Facebook被自动化后,如何调用函数? 我需要根据成功将它传递到另一个页面。如果它被授权我想把它转发给新的jsp。我怎么称呼这个功能? 我通过Fb.ui读到,我们可以编写回调函数。但是如何调用FB.ui?我试过但是如何调用FB.ui?
答案 0 :(得分: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 */
}
}
根据您的要求,您可以收听其他与auth相关的活动 - 请参阅facebook开发者文档,了解订阅活动的信息:http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/