0

我将以下代码用于likegate,但弹出登录对话框被阻止。我的一个朋友说我可以用 fb subscribe 事件来做。有人这样做过吗?除非有办法欺骗框以显示:页面而不是弹出窗口的形式打开。

任何帮助表示赞赏。

FB.getLoginStatus(function(response) {

        var page_id = "XXX";

      if (response && response.authResponse) {
        var user_id = response.authResponse.userID;
        var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
        FB.Data.query(fql_query).wait(function(rows) {
          if (rows.length == 1 && rows[0].uid == user_id) {
            console.log("LIKE");
            $('#container_like').show();
          } else {
            console.log("NO LIKEY");
            $('#container_notlike').show();
          }
        });
      } else {
        FB.login(function(response) {
          if (response && response.authResponse) {
            var user_id = response.authResponse.userID;
            var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
            FB.Data.query(fql_query).wait(function(rows) {
              if (rows.length == 1 && rows[0].uid == user_id) {
                console.log("LIKE");
                $('#container_like').show();
              } else {
                console.log("NO LIKEY");
                $('#container_notlike').show();
              }
            });
          } else {
            console.log("NO LIKEY");
            $('#container_notlike').show();
          }
        }, {scope: 'user_likes'});
      }
    });
  };
4

1 回答 1

1

我想出了 PHP 的方式,它更好更容易......这是所有尝试的人的代码:)

$facebook = new Facebook(array(
'appId' => 'XXXXXX',
'secret' => 'XXX',
'cookie' => true
));
$sr = $facebook->getSignedRequest();
?>

<?php if ($sr['page']['liked']): ?>
<-- STUFF IF A FAN -->

<?php else: ?>
<-- STUFF IF NOT A FAN -->

<?php endif; ?>
于 2012-09-12T16:43:38.640 回答