0

Facebookのファンページが訪問者に気に入られたかどうかを確認するにはどうすればよいですか. だから私は自分のapp_id、page_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>

その後、このエラーが発生します。

TypeError: FB.getSession is not a function
4

2 に答える 2

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')
 }});
于 2012-11-15T19:44:26.960 に答える
0

FB.getSession メソッドは廃止されました。FB.getAuthResponse代わりに使用してください。

于 2012-11-15T14:25:42.627 に答える