I make a page tab application. The application displays some items, each of which has a like button. Like buttons attached to the corresponding url item. I need to display to users who liked, some text in those elements that have collected 10+ likes. So, I write this code:
// Get a link statistics
$link_stat = $fb->api(
array(
'method' => 'fql.query',
'query' => 'SELECT like_count FROM link_stat WHERE url="http://myurl.com/item1.html"'
)
);
if ((int)$link_stat[0]['like_count'] > 10)
{
//Get like by current user_id and link object_id
$like = $fb->api(
array(
'method' => 'fql.query',
'query' => 'SELECT user_id, object_id FROM like WHERE user_id=me() AND object_id IN (SELECT id FROM object_url WHERE url="http://myurl.com/item1.html")'
)
);
var_dump($like);
}
I run this code upon request permission *user_likes* and *read_stream*, but it outputs array(0) { }
.
A question is, how do I know the current user liked corresponding link?
Oh, sh… I didn't notice that there is a table url_like (or recently emerged?). I made this FQL query, and it returned the required response:
SELECT user_id FROM url_like WHERE user_id = me() AND url = "http://myurl.com/item1.html"
Cpilko, thank you very much! =)