Display content after clicking Facebook Like button

前端 未结 3 1379
南笙
南笙 2020-12-29 12:09

I have a section of a webpage that I only want people to be able to access after clicking a Facebook Like button.

How do I hide that particular area and then displa

相关标签:
3条回答
  • 2020-12-29 12:50

    I'm not quite sure if this works. Remembering the f8 introduction of the like button facebook don't let website owners see who liked their page.

    The like button is rendered client side from the java script file hosted on facebook. I'm not a super java script expert, but I don't know a way to get variables from external java script files.

    The only idea I have is when a user made his likes public. You probably could read the cookie and then look up his likes on his public facebook page. As facebook loads most of it's content dynamically you can revers engineer the java script functions used on the public page by facebook internally, even if they are not part of the official API

    0 讨论(0)
  • 2020-12-29 12:53

    Another way is the plugin Like 2 Unlock for jQuery

    It allows to lock discounts, videos, download links, images, bonus content, forms and more. It’ll help you to increase the number of likes, to get additional traffic and more customers from the social network.

    0 讨论(0)
  • 2020-12-29 13:03

    Use 'edge.create':

    http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe

    really simple... can even couple it with jQuery.

    <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId   : '<?php echo $facebook->getAppId(); ?>',
                session : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it
                status  : true, // check login status
                cookie  : true, // enable cookies to allow the server to access the session
                xfbml   : true // parse XFBML
            });
    
            // whenever the user logs in, we refresh the page
            FB.Event.subscribe('auth.login', function() {
                window.location.reload();
            });
    
            FB.Event.subscribe('edge.create', function(response) {
                $.get('URLlink?uid=' + <?php echo $uid; ?>, function(data) {
                    $('#id').html(data);
                });
            });
        };
    
        (function() {
            var e = document.createElement('script');
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
        }());
    </script>
    
    0 讨论(0)
提交回复
热议问题