a digital blog

Tutorial

Share on Facebook to Unlock the Download Button

share-on-facebook-to-unlock-the-download-button-script-share

This post explains you about how to code Share on Facebook to Unlock the Download Button script. So for this first of all you need to create a facebook app, because to implement we need a facebook app id. So here is steps to create an facebook apps.

Demo & Download Link


  • Go to http://developer.facebook.com/
  • In top menu click to ”Create a New App”  under App link.
  • Fill the form details
  • Go to Settings and in App Domains enter website domain name
  • Click to Add Platform and select website, and in Add Platform enter your website url with “/” at the end and click to Save Changes and note down App ID. Now your app is ready.Share on Facebook to Unlock the Download Button

Add this code after your <body> tag

<div id="fb-root"></div>
<script type="text/javascript"
     src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
 appId : '147823442054624',
 status : true,
 cookie : true,
 xfbml : true
 });
</script>


Here is javascript function that is the core function for this script.

function shareToDownload(){
  FB.ui({
    method : 'feed',
    name : "Share Title",
    link : 'Share Link',
    picture: 'Share Image',
    caption: "Share Caption",
    description: "Share Description",
    message: "Share Message"
 }, function(response){
   if (response && !response.error_code) {
     /*Write your download code here*/
   }
 });
}

5 Comments

  1. very good blog content. It deserves to share.

  2. Waqas Khan

    very nice info, thanks for informing people like me

  3. do you think this will help us

  4. Does it work for ghost blogs and wordpress?


*

Copyright © 91 Web Lessons - a digital blog