2014-05-12 43 views
0

我需要做的是當用戶登錄遊戲並分享我們的adv圖片時,我想查看是否共享成功並添加額外的XP積分。所以我創建這樣的鏈接:如何檢查用戶是否在牆上分享信息?

<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=Title of sharer;&amp;p[summary]=Descriobe abiut game etc&amp;p[url]=http://google.com&amp;&amp;p[images][0]=http://www.some.jpg','sharer','toolbar=0,status=0,width=548,height=455');" href="javascript: void;"> 
test </a> 

所以我沒有反應的實現。我需要在fb中創建一些應用程序,並通過API使用我的APP ID或如何解決此問題?

回答

-1

您可以使用Facebook JavaScript SDK來跟蹤用戶是否成功地將某些內容共享到他們的牆上。 This tutorial顯示瞭如何實現這一點。

如果您分享一些使用FB.ui對話框中的牆,你可以回調添加到函數跟蹤成功/失敗,如下所示:

FB.ui({ 
    method: 'feed', 
    name: "Facebook API: Tracking Shares using the JavaScript SDK", 
    link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/", 
    picture: "https://stackexchange.com/users/flair/557969.png", 
    caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK." 
}, function(response) { 
    if (response !== null && typeof response.post_id !== 'undefined') { 
     console.log(response); 
     // ajax call to save response 
     $.post('{url_that_will_track_share}', { 'meta': response }, function(result) { 
     console.log(result); 
     }, 'json'); 
    } 
}); 

在這個例子中,回調的觸發器使用來自Feed對話框的響應調用另一個頁面的ajax。如果用戶分享了帖子,則回覆將包含post_id。您可以使用ajax腳本檢查post_id是否存在並且是否有效,然後相應地獎勵XP分數。

相關問題