Mit 'Facebook Login für das Web mit dem JavaScript SDK', ich habe eine Login-Taste, die gut funktioniert, dh Benutzer ist angemeldet, OK. (https://developers.facebook.com/docs/facebook-login/web#loginbutton).Facebook Login-Button nicht aktualisieren, um sich automatisch abzumelden
Die Schaltfläche ändert sich jedoch nicht zur Schaltfläche Abmelden, bis ich die Seite aktualisiere. Nach dem Aktualisieren wird die Schaltfläche "Abmelden" angezeigt. Wenn Sie darauf klicken, wird wie erwartet zur Schaltfläche "Anmeldung" zurückgekehrt. Es folgt der vollständige Code, der in IIS ausgeführt werden kann. Ich habe es in meine Standard-Website und rief http://localhost/aspnet_client/system_web/4_0_30319/test.html.
HINWEIS: Fügen Sie Ihre App-ID, wo es heißt, ADDIEREN SIE IHRE APP-ID HIER.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="row margin-bottom-small">
<div id="login-button" class="fb-login-button" data-max-rows="1" data-size="xlarge" data-show-faces="false" data-auto-logout-link="true" onlogin="checkLoginState();"></div>
<div id="status"></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.min.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
testAPI();
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 'ADD YOUR APP ID HERE',
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse social plugins on this page
version : 'v2.8' // use graph api version 2.8
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
</body>
</html>
FB-Code ist aus https://developers.facebook.com/docs/facebook-login/web#example
Ich will nicht programmatisch die Seite aktualisieren. Es ist eine einseitige Anwendung und das Aktualisieren der Seite bringt mich zum Start.
Danke.