是否可以添加链接以下载只能通过在Facebook上共享下载的文件?

Ian*_*ker 8 javascript facebook sharing download facebook-graph-api

这种情况可能吗?

客户访问我的网站,想要下载他们感兴趣的PDF技术文档,他们点击"下载"按钮,然后会出现Facebook共享窗口,将其登录以共享给Facebook.一旦他们点击共享并将其发布在他们的墙上,那么下载开始了吗?

非常感谢.

伊恩

Ada*_*zad 19

UPDATE

根据Facebook的新政策,这一行为是不允许的.使用风险由您自己承担.我不承担使用它的责任.

是的,使用JavaScript SDK,它提供了一个response(它不再是)我们将创建一个if语句,以查看响应是否有post_id显示下载链接否则执行其他操作(提醒用户,可能?)

DEMO(API 2.0)(不工作;需要修订)

DEMO(API 2.7)工作Rev#63

HTML

<div class="container">

    <div>
       <p>This file is locked, to unlock and download it, share it</p>
       <p class="hidden">Thanks for sharing, the file is unlocked and ready for download</p>
       <p class="hidden">In order to download this file, you need to share it</p>
    </div>

    <a class="fsl fsl-facebook" href="#" id="facebook-share">
       <span class="fa-facebook fa-icons fa-lg"></span>
       <span class="sc-label">Share on Facebook</span>
    </a>

    <a class="fsl content-download" href="#" id="download-file">
       <span class="fa-download fa-icons fa-lg"></span>
       <span class="sc-label">Download File</span>
    </a>

</div>
Run Code Online (Sandbox Code Playgroud)

JavaScript(jQuery)

$('#ShareToDownload').on('click', function(e) {
            e.preventDefault();
            FB.ui({
                  display: 'popup',
                  method:  'share',
                  href:    location.href,
                  },
                  /** our callback **/
                  function(response) {
                          if (response && response.post_id) {
                          /** the user shared the content on their Facebook, go ahead and continue to download **/
                          $('#ShareToDownload').fadeOut(function(){ $('#downloadSection').fadeIn() });    
                          } else {
                          /** the cancelled the share process, do something, for example **/
                          alert('Please share this page to download this file'):
                  }
            });     
}); 
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我建议你从JSON文件中获取下载链接,因为书呆子可以查看你的页面源,检查元素以获得下载并绕过你的调查

UPDATE

随着发布API 2.0版本饲料对话已被废弃,并用新的现代更换分享对话框所以上面的代码中使用了新的共享对话框