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

安稳与你 提交于 2019-12-06 14:50:10

问题


 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 ???


回答1:


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. FB doesnt let you know user's uid without their permission




回答2:


yes , i possible i did that by php with following code with out request and permission from user

        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

good luck :)



来源:https://stackoverflow.com/questions/19163343/ckeck-if-user-like-facebook-page-or-not-without-request-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!