Facebook API – Login with the JavaScript SDK
Html Tag:- <button id = "loginBtn" > Facebook Login </button> <div id = "response" > </div> Script Tag:- function getUserData ( ) { FB . api ( 'me?fields=link,id,first_name,last _name, email,gender,locale,timezone,verified,picture,age_range' , function ( response ) { document . getElementById ( 'response' ) . innerHTML = 'Hello ' + response . name ; } ) ; } window . fbAsyncInit = function ( ) { //SDK loaded, initialize it FB . init ( { appId : 'your-app-id' , xfbml : true , version : 'v2.2' } ) ; //check user session and refresh it FB . getLoginStatus ( function ( response ) { if ( response . status === 'connected' ) { //user is authorized document . getElementById ( 'loginBtn' ) . style . display = 'none' ; getUserData ( ) ; } else { //user is n