如何检查Facebook页面是否被用户喜欢?

时间:2013-01-22 08:40:36

标签: javascript facebook

我的页面上有一个类似的按钮,我只想查看用户是否喜欢该页面的天气。以下是我的代码。我正在展示那些喜欢该页面的用户的面孔。

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like-box" data-href="my-page-url" data-width="175" height="400" data-show-faces="true" data-stream="false" data-header="false" border_color="#CCCCCC"></div>

先谢谢 问候, Asif Hameed

1 个答案:

答案 0 :(得分:0)

FB.api('/ me',功能(响应){
         var user_id = response.id;
         var page_id = your_page_id;
         var fql_query =“SELECT uid FROM page_fan WHERE page_id =”+ page_id +“and uid =”+ user_id;
         var the_query = FB.Data.query(fql_query);
          the_query.wait(function(rows){
              if(rows.length == 1&amp;&amp; rows [0] .uid == user_id){                  //做你想做的事               其他{
                 //不喜欢..               }
          });
        });