【问题标题】:how to get the +1 count in google plus using any API如何使用任何 API 在 google plus 中获得 +1 计数
【发布时间】:2013-03-12 17:11:33
【问题描述】:

我已经尝试了很多东西,但我无法获得一个合适的 API,它将返回我在 google plus 中的 +1 计数。

我已经尝试过使用:-

Getting Counts for Twitter links, Facebook likes and Google +1 with Jquery and AJAX

Getting Google+ subscription count with jQuery

How do I get the counter of a google plus +1 button?

但他们都没有给我答案。

任何想法......

谢谢:)

【问题讨论】:

标签: javascript google-api google-plus google-plus-one


【解决方案1】:

我刚刚发现了一个非常有用的网站来解决我们的问题。 :) 感谢他! http://99webtools.com/script-to-get-shared-count.php

【讨论】:

    【解决方案2】:

    您可以使用the link you and jgillich mentioned 编写自己的函数。这将使用 jQuery 稍微简化。

    这是我作为示例制作的jsfiddle。如果您想规避域间问题,您可能必须使用 PHP 之类的东西从站点获取。它可能看起来像这样(忽略域):

    $('#myInput').keyup(function () {
        var url = 'https://plusone.google.com/_/+1/fastbutton?url=' + encodeURIComponent($(this).val());
        $.get(url,
            function (data) {
                var aggregate = $('#aggregateCount', data).html(),
                    exactMatch = $('script', data).html().match('\\s*c\\s*:\\s*(\\d+)');
    
                $('div').html(exactMatch ? exactMatch[1] + ' (' + aggregate + ')' : aggregate);
            }
        );
    });
    

    【讨论】:

    • 是的,这是一种非官方的、不受支持的方法。如here 所述,URL 似乎已更改。它在三月份开始工作。
    【解决方案3】:

    目前,API 不提供任何方法来检索 +1 计数。一种解决方法是直接从 +1 按钮中获取它,如 here 所述(您已经链接到它,但我认为没有其他方法)。

    【讨论】:

      【解决方案4】:

      这对我有用:

      var _url = 'http://mylink.com/';   
      $.getJSON('http://anyorigin.com/get?callback=?&url=' + encodeURIComponent('https://plusone.google.com/_/+1/fastbutton?url=' + _url)).done(function(data,status,xhr){
          console.log($(data.contents).find('#aggregateCount').html());
      });
      

      【讨论】:

        【解决方案5】:

        查看以下获取 Google+ 人数的另一种方法。

        http://share.yandex.ru/gpp.xml?url=http://google.com

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多