Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This call requires a Page access token

I am trying to login with facebook, which is done. I need to get user info like name, email, hometown, location, gender, profile_pic. But i can only get username of the logged in user. I also added fields parameter to api. You can see that in below code.

<div id="container"></div>
<script>
 var accessToken;
 window.fbAsyncInit = function() {
   FB.init({
    appId      : 'App Id',
    cookie     : true,
    xfbml      : true,
    version    : 'v3.1'
   });

   FB.AppEvents.logPageView();   

   function getuserProfile() {
    FB.api('/me?fields=id,name,email,birthday,gender,hometown,location,profile_pic', {access_token : accessToken }, function (response){
      console.log(response);
    });
 }  

FB.login(function(response) {
  if (response.status === 'connected') {
    accessToken = response.authResponse.accessToken;
    getuserProfile();
  } else {
    console.log('not connected');
  }
}, {scope: 'email'});  
};

(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 = "https://connect.facebook.net/en_US/sdk.js";
  fjs.parentNode.insertBefore(js, fjs);
 }(document, 'script', 'facebook-jssdk'));


1 Answers

Some fields can be specified wrong and that is why Facebook API is giving such an error even when everything else seems fine. For instance profile_pic field can cause such an error which should be something like picture.type(large). See also: FacebookGraphAPIError: (#210) This call requires a Page access token

like image 108
Nikita Vlasenko Avatar answered Oct 19 '25 15:10

Nikita Vlasenko