嗨,我是 facebook APP 的新手。我正在研究 Facebook C# SDK 和 Javascript SDK。但问题是我无法获得 AccessToken,也无法调试代码。请找到以下代码
<div id="fb-root"></div> <!-- This initializes the FB controls-->
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'XXXXXXXXXXXXXXX', // App ID
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
// Additional initialization code here
alert("Additional initialization code here");
FB.Event.subscribe('auth.login', function (response)
{
debugger; ****//Debugger is not Raising****
if (response.status === 'connected') {
// connected
alert("Connected");
} else if (response.status === 'not_authorized') {
// not_authorized
} else {
// not_logged_in
}
});
FB.getLoginStatus(function (response) {
if (response.session) {
// logged in and connected user, someone you know
alert("Connected");
} else {
// no user session available, someone you dont know
}
});
FB.Event.subscribe('auth.authResponseChange', function (response) {
alert("Additional initialization code here");
if (response.status === 'connected') {
alert("Bhuvan"); `// Event Not Raising`
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
debugger;
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
// TODO: Handle the access token
// Do a post to the server to finish the logon
// This is a form post since we don't want to use AJAX
var form = document.createElement("form");
form.setAttribute("method", 'post');
form.setAttribute("action", 'FacebookLogin.aspx');
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", 'accessToken');
field.setAttribute("value", accessToken);
form.appendChild(field);
document.body.appendChild(form);
form.submit();
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
}
});
};
// 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 = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
} (document));
</script>
<div class="fb-login-button" data-show-faces="true" data-width="400" data-max-rows="1"></div>
我能够登录,但我无法处理任何事件。我可以知道为什么我无法引发事件,以及为什么我无法检索访问代码吗?