-1

I have a own page on my server where people can download a track of my own.

My idea is to put a like button on that page to my Facebook page. People must first hit the like button, and after that they can download the track. Probably this must fix with a form with name, e-mail and the like button that they have to click! After submit, there must be something that will check if the user realy hit the like button before they get the page with the special content (download link)

So the idea is if it is possible that there's a check that the page is liked before they can submit and get the download button!

Can someone tell me if this is possible and can someone help me with the code? I have no other Facebook social plugins! I only want to use a like button!

Hubert Kario
  • 21,314
  • 3
  • 24
  • 44
  • well, i tried to put the like button with his code in a hyperlink but that doesn't work! It looks very easy what i want but don't know how to fix it :( – Mark van Lith Jan 03 '12 at 11:14
  • Please don't reask the same question. –  Jan 04 '12 at 15:17

2 Answers2

2

You can check if someone clicks the like button using the Javascript SDK

You can either use the social plugin or the XFBML button, Implementing the XFBML button and the Javascript SDK you can find here: https://developers.facebook.com/docs/reference/javascript/

Then you can create an event listener that listens if an user clicks the like button:

FB.Event.subscribe('edge.create',
    function(response) {
        alert('You liked the URL: ' + response);
    } 
);

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

Using this you can store if someone clicked the like button then save that to either your database or in a session and let the user download their track.

Your code would be something like this

<div id="fb-root"></div>
<div class="fb-like" data-href="http://www.stackoverflow.com" data-send="false" data-width="450" data-show-faces="true"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : 'YOUR_APP_ID', // App ID
            channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
        });

        FB.Event.subscribe('edge.create',
            function(response) {
                alert('You liked the URL: ' + response);
            } 
        );
    };

// Load the SDK Asynchronously
(function(d){
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
}(document));

MarkSmits
  • 538
  • 2
  • 7
0

It is possible to do what you're asking. You may find this SO question and answer useful:

How to check if a user likes my Facebook Page or URL using Facebook's API

Community
  • 1
  • 1
Jarede
  • 3,310
  • 4
  • 44
  • 68