2016-11-29 58 views
0

我想在用戶在fb上共享帖子時更新我的​​數據庫。我正在使用Facebook SDK進行JAVASCRIPT。如何更新mysql中的數據當用戶使用Facebook SDK for JavaScript在Facebook上發佈帖子時

我的代碼是: -

<script> 
     document.getElementById('shareBtn').onclick = function() { 
      FB.ui({ 
      method: 'share', 
      display: 'popup', 
      href: 'url goes here', 
      }, function(response){ 
       if (response && response.post_id) { 
         //ajax code goes here for database update 
        } else { 
         alert('oops post was not published'); 
        } 
      }); 
     } 
     </script> 

按鈕代碼 -

<div class="fb-share-button" 
    data-href="url goes here" 
    data-layout="button" data-size="large"> 
    </div> 

我能夠分享的信息,但如何更新MySQL的數據時,用戶成功股吧發帖

+1

看到我的答案。這個btw的用例是什麼?爲什麼你要更新數據庫,如果用戶分享了一些東西? – luschn

+0

@luschn其實我正在一個項目中,當用戶成功分享帖子時獎勵用戶 –

+1

這甚至不允許......你不能以任何方式獎勵用戶分享。在繼續之前,您應該閱讀[平臺策略](https://developers.facebook.com/policy)。 – CBroe

回答

1

你只會在用戶授權publish_actions權限的情況下共享某些內容。該權限需要通過Facebook進行審查,Facebook不會僅僅爲此而批准它,恐怕。

換句話說:這是不可能的。

相關問題