如何获得+1计数在谷歌加上使用任何API

how to get the +1 count in google plus using any API

本文关键字:任何 API 谷歌 何获得      更新时间:2023-09-26

我已经尝试了很多事情,但我无法得到一个适当的API,这将返回我在google + +1计数。

我已经试过使用:-

使用Jquery和AJAX获取Twitter链接,Facebook点赞和Google +1的计数

使用jQuery获取Google+订阅数

如何获得google + +1按钮的计数器?

但是没有一个人给我答案。

任何想法…

谢谢:)

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

您可以使用您和jgillich提到的链接编写自己的函数。使用jQuery可以稍微简化一下。

这是我做的一个例子。如果您想规避域间问题,可能必须使用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);
        }
    );
});

目前,API没有提供任何方法来检索+1计数。一个解决方法是直接从+1按钮获取它,就像这里描述的(你已经链接到它,但我不认为有另一种方法)。

这个适合我:

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

查看下面的另一种获取Google+计数的方法。

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