duan0417 2016-10-19 17:09
浏览 82


I have a Facebook share button on a page, And now the user shares a post on his/her timeline, Now what i want to do is count the number of times that specific user shares it in that session.

For Example the count will be initialized to 0 for all users , What i want is Each time a person shares a post successfully the count to increment.

We create a variable count and initialize to 0, now the share button works fine, How can i increment the count each time the post is successfully shared? What variables would be needed and how can this be done?

$fbcount = $_SESSION['count'];

function incrememnt() {

document.getElementById('shareBtn').onclick = function() {
    method: 'share',
    display: 'popup',
    href: 'https://developers.facebook.com/docs/',
  }, function(response){});
  • 写回答

1条回答 默认 最新

  • dongza3124 2016-10-19 17:38

    I'm not sure of the exact syntax without seeing the properties on the response object, but you should be able to do something like:

      document.getElementById('shareBtn').onclick = function() {
            method: 'share',
            display: 'popup',
            href: 'https://developers.facebook.com/docs/',
          }, function(response){
                 if(response.statusCode == '200'){

    You will likely have to change response.statusCode to whatever property you actually have on the response object.

    This would also be a good place for error handling. Maybe throw an else after the if to do something if it's anything but 200.

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



  • ¥50 手写签名不能上传的问题
  • ¥30 linux odbc怎么添加gbase数据库
  • ¥20 电脑开机黑屏,只有一个鼠标,联想zj者y7000
  • ¥20 DXSDK_jun10
  • ¥20 请问这种量表怎么用spss量化分析(作为中介模型的因变量
  • ¥55 AD844 howland电流源如何驱动大额负载
  • ¥15 C++ /QT 内存权限的判断函数列举
  • ¥15 深度学习GFnet理解问题
  • ¥15 单细胞小提琴堆叠图代码
  • ¥50 升级strust2版本到2.3.15.1后使用ognl3.0.6.jar windows环境中没有问题,但部署到linux环境报错