Kako povuc USER_ID sa Facebooka?

Pozdrav svima,

Danas sam probao nac kako doc do USER_ID sa facebooka i nigdje preko apija nisam nasao nacin. Jedan od nacina je bio otiso sam na svoj profil i find “USER_ID” ili “PROFILE_ID” i tada sam nasao. Takoder ima jos jedan nacin a to je pregledavanje cookia pod name “C_USER”.

Preko apija sam uspio dovuc ID sa facebooka ali ID i USER_ID su skroz razliciti brojevi.

U ovom formatu bi trebalo otvorit vas facebook profil.
https://www.facebook.com/app_scoped_user_id/{USER_ID}.

evo i javascript kod sam kojim sam uspio dovuc ID i usera.

<script>
function getUserData() {
    	FB.api('/me', 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 not authorized
    		}
    	});
    };
     
    //load the JavaScript SDK
    (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'));
     
    //add event listener to login button
    document.getElementById('loginBtn').addEventListener('click', function() {
    	//do the login
    	FB.login(function(response) {
    		if (response.authResponse) {
    			//user just authorized your app
    			document.getElementById('loginBtn').style.display = 'none';
    			getUserData();
    		}
    	}, {scope: 'email,public_profile', return_scopes: true});
    }, false);
</script>

HTML dio:
< button id=“loginBtn” >Facebook Login< /button>
< div id=“response” >< /div >


Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Profit Monkey