简体   繁体   English

如果用户没有请求访问令牌,是否喜欢Facebook页面,请单击

[英]ckeck if user like Facebook page or not without request Access Token

 window.fbAsyncInit = function() {
        FB.init({
          appId      : '********', // App ID
          channelUrl : document.location.protocol + '//connect.facebook.net/en_US/all.js', // Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true  // parse XFBML
        });


 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();
              }             }

just i need to check user like Facebook page or not with out request any access token or permission is that possible ??? 只是我需要检查用户是否喜欢Facebook页面,而不需要任何访问令牌或许可,这可能吗?

I dont think it's possible if I'm understanding you correctly... ultimately youre always going to need the user to authorize your app and get an auth token in order to know the user's id. 我认为如果我正确地理解了您是不可能的...最终,您始终总是需要用户授权您的应用程序并获取身份验证令牌才能知道用户的ID。 FB doesnt let you know user's uid without their permission FB不会在未经用户许可的情况下让您知道用户的uid

yes , i possible i did that by php with following code with out request and permission from user 是的,我可以通过以下代码通过php进行操作,而无需用户的请求和许可

        require 'src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
        $facebook = new Facebook( array(
            'appId' => '***************',
            'secret' => '**********************',
            'cookie' => true,
                ) );
        $signed_request = $facebook->getSignedRequest();
// Return you the Page like status
        $like_status = $signed_request[ "page" ][ "liked" ];

        if ( $like_status ) {?>
            <div class="facebook-data-content" id="facebook-data-content"> </div>

        <?php } else {
            ?>
            <div class="like-gate" id="like-gate"> </div>
        <?php } ?>

and you can do the same with JavaScript note : all need check that redirect URL correct first before do anything because most problem about this issues 并且您可以使用JavaScript注释进行相同操作:在进行任何操作之前,所有人都需要先检查重定向URL是否正确,因为有关此问题的大多数问题

good luck :) 祝好运 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM