Check if a Facebook user likes a page using fql

北慕城南 提交于 2019-12-07 12:42:02

问题


I want to check whether the loggedIn user has liked a specified page or not. Below is my code.

$fql_pageid = "SELECT url,site,id FROM object_url WHERE url    
                     IN('http://developers.facebook.com/')";
$api_pageid = $facebook->api(array(
                    'method' => 'fql.query',
                    'query' => $fql_pageid
));
$pageid = $api_pageid[0]["id"]; //get id of the specified page
$fql_like = 'SELECT object_id FROM like WHERE user_id=me()';
$api_like = $facebook->api(array(
                    'method' => 'fql.query',
                    'query' => $fql_like
));

When I do var_dump($api_like), there are only 6 records appearing. But I checked my Facebook account, there are 22 likes.

Anyone knows what's wrong the above code? Or is there any other way to check whether a user has liked a specified page?


回答1:


Let's say that you want to check if the current user (uid=me()) is Fan of the "Big Bang Theory" page with *page_id=22934684677* (http://graph.facebook.com/TheBigBangTheory) you should run this query:

SELECT page_id FROM page_fan WHERE uid=me() AND page_id=22934684677



回答2:


If instead you want to see if the current user likes a website:

SELECT user_id FROM url_like WHERE url='http://someurl.com' AND user_id=me()

This is useful for page tab apps where normal like buttons will only like the page the tab resides in.



来源:https://stackoverflow.com/questions/9012205/check-if-a-facebook-user-likes-a-page-using-fql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!