Check if someone likes page before submit on own website

前端 未结 2 1865
再見小時候
再見小時候 2021-01-17 06:01

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 t

2条回答
  •  醉酒成梦
    2021-01-17 06:42

    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

提交回复
热议问题