Claudius Rehme
Claudius Rehme

Reputation: 57

Get Google+ shares without API key for each page?

On a search result page I would like to get the count of Google+ shares for the URL of each search result item via Ajax. I already managed to set up counting functions for Facebook and Twitter:

    $.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + url + '&callback=?', function(data){
        tweets = data.count;
    });

    $.getJSON('https://api.facebook.com/method/links.getStats?urls='+ url+'&format=json', function(data){
        fblikes = data[url].shares;
    });

For Google+ I also already found a solution, but this requires the API Key for each URL. Is there any way to retrieve the Google+ count without such a key? Using it for tons of dynamically loaded search results, of course I cannot create an API key for each search result URL.

Upvotes: 2

Views: 2457

Answers (1)

Tobi
Tobi

Reputation: 31479

Yes, it's possible to get Google +1 counts. They are retrieved via a JSON-RPC POST call.

POST URL:

https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ 

POST Body:

[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"%%URL%%","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]

where %%URL%% is the desired URL.

Have a look at the following:

Upvotes: 5

Related Questions