I have a canvas application that tries to check if user is a fan with this code:
$params = array(
'method' => 'fql.query',
'query' => "SELECT uid FROM page_fan WHERE page_id='MY_APP_ID' and uid = me()",
);
$result = $facebook->api($params);
The $result[0] is not set, and therefore is empty, even though I have liked the app.
Any suggestions?
thanks
It appears that there are two likely issues here –
You have not requested the
user_likespermission from your users. You will need this permission to access any data on a users “likes”.This permission is required no matter how you intend to retrieve the information, server side or client side, with or without an SDK.
You have specified your application’s ID instead of a
PAGE_IDin your FQL query. Users can not “like” an application in the same way that they can not “like” another user.You can create a page for your application from within it’s “App Details” page. You can navigate to
https://developers.facebook.com/apps/APP_ID/appdetailsand scroll down to the “contact info” section. There you will see a “Create Facebook Page” button.Once you have created an App Page, you’ll be able to use it’s
PAGE_IDto let your users “like” it and then will be able to verify the like action from within your application.