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

5

7

I have tried many things but I'm not able to get a proper API which will return me the +1 count in google plus.

I have already tried using :-

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?

But none of them is giving me the answer.

Any thoughts....

Thanks :)

Courteous answered 12/3, 2013 at 17:11 Comment(1)
possible duplicate of How do I get the counter of a google plus +1 button?Audryaudrye
I
4

i just found out a very useful site to solve our problem. :) Thanks to him! http://99webtools.com/script-to-get-shared-count.php

Interflow answered 17/12, 2013 at 17:34 Comment(0)
A
2

You could write your own function using the link you and jgillich mentioned. This would be slightly simplified with jQuery.

Here's a jsfiddle I made as an example. You'll probably have to use something like PHP to fetch from the site if you want to circumvent inter-domain issues. It could look something like this though (ignoring domains):

$('#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);
        }
    );
});
Audryaudrye answered 12/3, 2013 at 19:48 Comment(1)
Yes, this is an unofficial, unsupported method. It seems the URL has changed, as noted here. It was working back in March.Audryaudrye
F
1

Currently, the API does not offer any method to retrieve the +1 count. A workaround would be to fetch it directly from the +1 button like described here (you already linked to it, but I don't think there is another way).

Forwhy answered 12/3, 2013 at 18:11 Comment(0)
I
1

this works for me :

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());
});
Isometropia answered 30/4, 2015 at 12:26 Comment(0)
D
-1

Check out the following for another way to get the Google+ count.

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

Decennary answered 2/4, 2014 at 21:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.