已编写使用FaceBook Connect API的代码。点击Facebook按钮,登录窗口打开,我输入我的Facebook凭据并登录到Facebook,但我的回电功能,我应该得到来自Facebook的响应没有被调用。任何人都可以告诉我哪里出错了。
<script type="text/javascript">
$("document").ready(function () {
// Initialize the SDK upon load
FB.init({
appId: 'My APP ID', // App ID
scope: 'id,name,gender,user_birthday,email',
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
// listen for and handle auth.statusChange events
//FB.Event.subscribe('auth.login', OnLogin);
FB.Event.subscribe('auth.login', function(response) {
alert('The status of the session is: ' + response.status);
});
});
// This method will be called after the user login into facebook.
function OnLogin(response) {
if (response.authResponse) {
FB.api('/me?fields=id,name,gender,email,birthday', LoadValues);
}
}
//This method will load the values to the labels
function LoadValues (me) {
if (me.name) {
alert(me.name);
}
}
</script>