Perhaps you could just store the path server side and have the frontend pass a special code to a remote endpoint once the item has been "liked".
$([however you're binding to the like button]).on('click', function() {
$.getJSON('/download_link.php', {'key': <some unique key>}, function(response) {
if(response.status == 'valid') {
$('<div><a href="' + response.path + '">Download the item now!</a></div>').appendTo('body');
}
else {
alert('invalid security key');
}
});
});
If you're worried about people easily seeing the routine, then go to packer (http://dean.edwards.name/packer/). It's not secure but it will deter your average joe from seeing the code easily.
FYI the code above looks like this when packed:
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$([m h\'9 e l 2 5 6]).7(\'8\', 3() {\n $.b(\'/c.d\', {\'1\': <f g 1>}, 3(0) {\n i(0.j == \'k\') {\n $(\'<4><a n="\' + 0.o + \'">p 2 q r!</a></4>\').s(\'t\');\n }\n u {\n v(\'w x 1\')}})});',34,34,'response|key|the|function|div|like|button|on|click|re||getJSON|download_link|php|binding|some|unique|you|if|status|valid|to|however|href|path|Download|item|now|appendTo|body|else|alert|invalid|security'.split('|'),0,{}))
You'll need to return the following from the download_link.php
file:
<?php
if(valid_key($_REQUEST['key'])) {
header('Content-Type: application/json');
echo json_encode(array('status' => 'valid', 'path' => generate_secret_path()));
}
?>
Hope that helps.