I am using JavaScript SDK of Facebook for signup with Facebook button in my site. I have used this script:
<div id="fb-root"></div>
<img onclick="fb_login();" src="public/images/facebook_signup.jpg" id="fb-login" style="vertical-align: middle; margin-top: -1px; cursor: pointer;" alt="Sign up with facebook">
<script type="text/javascript">
FB.init({appId: '423901a20718dce67e82992eeb6f41bf', status: true, cookie: true, xfbml: true, oauth: true});
function fb_login() {
FB.login(function(response) {
if(response.authResponse) {
console.log('Welcome! Fetching your information.... ');
}
},{scope:'email,user_birthday,offline_access,publish_stream,read_friendlists'});
}
function fb_logout() {
FB.logout(function(response) {
if(response.authResponse) {
}
});
}
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.authResponse) {
// A user has logged in, and a new cookie has been saved
} else {
// The user has logged out, and the cookie has been cleared
}
});
</script>
But when click on button then it gives an Facebook error “An error occurred. Please try again later.”.
Any help will be appreciated.
1 Answer