doudao1369 2014-10-02 21:47
浏览 31
已采纳

Facebook API:如何获取特定用户的URL份额?

I am building a web campaign app where the user oauths then has a selection of 20 different sharable images. I need to keep track of how many times the user shares total and potentially which ones they share.

The second and easier option is to keep track of the count when they click the share button on the page. Though this wont give an accurate count as the user could click the share button on the site, wait for the .sharer window to pop up, close it and ultimately game the site. I'd like to avoid that.

Is there another way to keep track of what he user is sharing?

I am building this in Cakephp.

  • 写回答

1条回答 默认 最新

  • douzhenggui8171 2014-10-03 10:09
    关注

    If you use the JavaScript SDK, you can track what the user shares, and only when it's successfully shared. The basic code to achieve this below. You can send unique identifiers for each image so you know which one was shared. Of course, this can still be gamed by the user - they can share an image and then delete it from their timeline.

    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
            }
        } );
    
    }
    

    You can find the complete code and working example here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!