0

I am having a problem with return if user has liked a certain page.

If I try it with my admin userID

FB.api("/me/likes/259239627467123",.. return correct: [Object { category="Travel/leisure", name="KatkaFodor Bt.", created_time="2014-07-10T13:33:54+0000", ...}]

But if I have another userID FB.api("/me/likes/259239627467123",.. return empty data: Array[0]

Where is my problem?

var token='';

window.fbAsyncInit = function() {
        FB.init({
          appId      : '1506526099561855', // App ID
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true,  // parse XFBML
          scope: 'user_likes',
        });

        FB.getLoginStatus(function(response){
            console.log("Token:"+response.authResponse.accessToken);
            console.log("User ID:"+response.authResponse.userID);

            token=response.authResponse.accessToken;
            FB.api(
                "/me/likes/259239627467123",
                function (response) {
                    if (response && !response.error) {
                        console.log(response);
                        /* handle the result */
                        console.log("User likey!");
                        //document.getElementById('nolikey').style.display = "none";
                    } else {
                        console.log("User no likey :("+response.error.message);
                    }
                }
                ,{access_token: token});
        });

};
// Load the SDK asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));


function Login()
{
        FB.login(function(response) {
            if (response.authResponse) 
            {
                getUserInfo();
            }
            else 
            {
                console.log('User cancelled login or did not fully authorize.');
            }
         },{scope: 'email,user_likes'});

}

function getUserInfo()
{
    FB.api('/me', function(response) {
    console.log(response);

    var str="<b>Name</b> : "+response.name+"<br>";
      str +="<b>Link: </b>"+response.link+"<br>";
      str +="<b>id: </b>"+response.id+"<br>";
      str +="<b>Email:</b> "+response.email+"<br>";
      document.getElementById("status").innerHTML=str;

   });
}

1 Answer 1

0

The "user_likes" permission has to get approved by the Facebook team in order to be available for users who are not app admins.

See the Changelog for more information: https://developers.facebook.com/docs/apps/changelog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.