2012-11-15 3 views

답변

0

FB.getSession 방법이있다 : 그래서 내 APP_ID을 작성하여 코드

의 페이지 ID 이것은 내가 지금은 나중에이 오류가

<div id="fb-root"></div> 
<script src="http://connect.facebook.net/en_US/all.js"></script> 
<script> 
    FB.init({ 
    appId : 'APP_ID', 
    status : true, // check login status 
    cookie : true, // enable cookies to allow the server to access the session 
    xfbml : true, // parse XFBML 
    channelUrl : 'http://domain.com/tab/', // channel.html file 
    oauth : false // enable OAuth 2.0 
    }); 

(function($) { 

    var session = FB.getSession(); 
     FB.api({ 
      method: 'fql.query', 
      query: 'SELECT uid, page_id FROM page_fan WHERE uid=me() AND page_id=PAGE_ID' 
     }, 
    function(response) { 
     if(response instanceof Array && response.length > 0) 
      alert("YOU LIKE US!"); 
     else 
      alert("YOU DON'T LIKE US YET!"); 
    }); 
})(jQuery); 
</script> 

있어 코드입니다 더 이상 사용되지 않습니다. 대신 FB.getAuthResponse을 사용하십시오. 현재 사용자가 이미 페이지 또는하지를 좋아하는 경우

2

, 당신은 다음과 같이 처리 할 수 ​​

FB.api("me/likes/PAGE_ID", function(response) { 
   if (response.data.length == 1) { //there should be a single value inside `data` which is your page details 
  
      alert('you like us :-)') 
     } else { 
        alert('please like our page') 
 }}); 
+1

을이에 대한 user_likes을 필요 해요 –

관련 문제