I am creating my first app in facebook. In that i am trying to access the user's page account details. I used this code:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
alert('connected');
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
getusername();
}
Here i can able to get the user's main account id ,access_token, name everything. For getting the user's page account details i used this code
function getusername(){
FB.api('/me/accounts', function(response){
var p_accessToken = response.accessToken;
var p_name = response.name;
alert('The pagename is:'+ p_name + 'Page access token is' + p_accessToken);
});
But it alerted the name and access_token as undefined. I dont know how to access the name, access_token of the page.
I think I need to change this p_accessToken =response.accessToken line.
But i dont know how to get this. Can anyone help me .