Facebook API:如何获取特定用户的URL共享数量


Facebook API: How to get number of shares of a URL by a specific user?

我正在构建一个网络活动应用程序,用户可以在其中选择20个不同的可共享图像。我需要跟踪用户总共共享了多少次,以及他们可能共享了哪些。

第二个也是更容易的选择是,当他们点击页面上的共享按钮时,跟踪计数。虽然这不会给出准确的计数,因为用户可以点击网站上的共享按钮,但请等待.sharer窗口弹出,关闭它,最终游戏网站。我想避免那样。

有没有其他方法可以跟踪用户正在共享的内容?

我正在Cakephp中构建这个。

如果您使用JavaScript SDK,您可以跟踪用户共享的内容,并且只有在成功共享时才能跟踪。实现这一点的基本代码如下。您可以为每个图像发送唯一的标识符,这样您就可以知道哪个图像是共享的。当然,用户仍然可以玩这个游戏——他们可以共享一张图像,然后将其从时间线中删除。

function fb_share() {
    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' ) {
          // ajax call to track share
        }
    } );
}

您可以在这里找到完整的代码和工作示例。