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.

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

报告相同问题?

悬赏问题

  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'
  • ¥15 vue+element项目中多tag时,切换Tab时iframe套第三方html页面需要实现不刷新