I got it from a website don't remember the link and credits to the author for this code.
Steps:
1. Create a landing page
2. create a button like 'download now'
3. On click of this button call this page
4. You will have to create facebook app id to work and provide your own download links
What you can do with this is when someone visits your landing page, the user clicks the download button and will be redirected to this page. Once redirected the user will have to share the page on facebook. If he shares he will be automatically redirected to the download link
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Facebook Share to Unlock Content</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
function shareOnFB() {
var e = {
method: "feed",
link: "http://xyz.com",
picture: "http://xyz.com/image.png",
name: "Make money - online, make money",
caption: 'xyz.com',
description: "PUT DESCRIPTION HERE"
};
FB.ui(e, function(t) {
if (t["post_id"]) {
//your download content goes here
// Do something there
var secret_data = "<h2 class=\"stitle1\">Thank you!</h2><h2 class=\"stitle2\">You can use the content below to download</h2><p class=\"d_link\"><a href=\"https://app.box.com/s/mqb29ed1pl2kh9h6x1bq\">https://app.box.com/s/mqb29ed1pl2kh9h6x1bq</a></p>";
jQuery("#results").html(secret_data);
}
})
}
</script>
<link href="style.css" media="all" rel="stylesheet" type="text/css" />
<style type="text/css">
#keyword { height: 30px; padding: 2px;}
.ajax_indi { display: none;}
.stitle1{ color: #444; font-size: 21px; text-align: center; margin-top: 10px;}
.stitle2{ color: #777; font-size: 18px; text-align: center; margin-top: 5px;}
p.d_link { color: red; font-weight: bold; margin-top: 10px; text-align: center;}
</style>
</head>
<body style="background:#ccc;">
<div style="background:#fff; width:20%; margin:0 auto; padding:20px;">
<center><h1 style="padding:0; margin:0;">Get Your Premium Content </h1></center>
<br />
<br/><br/>
<div id="results">
<p>Download content is locked! Please share it & unlock the content</p>
<center>
<img onclick="shareOnFB();" style="cursor

ointer" src="https://d1wofkmqsniyp0.cloudfront.net/public/v2.0/imgs/fbshare.png">
</center>
</div>
<br/><br/><br/><br/><br/>
</div>
<!-- Start of Woopra Code -->
<script type="text/javascript">
function woopraReady(tracker) {
tracker.setDomain('w3lessons.info');
tracker.setIdleTimeout(1800000);
tracker.track();
return false;
}
(function() {
var wsc = document.createElement('script');
wsc.src = document.location.protocol+'//static.woopra.com/js/woopra.js';
wsc.type = 'text/javascript';
wsc.async = true;
var ssc = document.getElementsByTagName('script')[0];
ssc.parentNode.insertBefore(wsc, ssc);
})();
</script>
<!-- End of Woopra Code -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=145839838947717&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
</body>
</html>