问题
I've developed a PHP app which just need to get if the user has liked a certain page.
I login the user this way:
$this->_facebook = new Facebook(array(
'appId' => "123",
'secret' => "346",
));
$this->_facebookUser = $this->_facebook->getUser();
$this->_facebook->api('/me');
and then
$checkIfUserLikePage = $this->_facebook->api(array(
"method" => "fql.query",
"query" => "select uid from page_fan where uid=me() and page_id=" . $pageid,
));
This mostly works but for some users does not, it returns an empty array. I've checked online and my app is probably missing the *user_likes* permission. And in fact I didn't have this permission. So again I found I should add the permission, uninstall the app and retry.
So I:
- logged to developer.facebook.com > apps > myapp > App details > Configure App Center Permissions
- added "user_likes" to the User and Friend Permissions text area
- saved
- asked a test user to remove myapp
- asked the test user to access the app
As a result I still get an empty array for the user. What else is wrong? thanks
回答1:
Don't mistake the permissions in the app center with those you pass to your scope. When prompting the user for permissions, do you have added "user_likes" to the scope?
With the JS-SDK you do it like that for example:
FB.login(function(response) {
// Do some fancy stuff
}, {scope: 'user_likes'});
Also make sure you have a valid user access token. Your PHP-SDK provides a method called "getAccessToken()", which returns the current access token.
You can also simply try to print the results of getUser() which returns the userID of the current user. If you get 0, you can be pretty sure that the user is not connected with your facebook app and you'll therefore not be able to use me() in FQL queries.
Also query the graph API with /{user-id}/permissions
. You'll get a json object returned that contains all the permissions the user gave. Of course you need a valid connected user with your app in order to do that.
I hope I could give you some helpful advice. If nothing helped try posting more code.
Happy Coding!
来源:https://stackoverflow.com/questions/20541335/cannot-get-page-like-for-some-users