Open OB80 opened 11 years ago
You could make a modification to the javascript to get the counts. You can get google plus counts via a CORS request, but you need to have a google API key (and restrict it to your website domain, so other people don't steal it and use up your daily quota) so that they will enable the CORS headers on the JSON response.
There would be a need to add a new parameter for the google+ key. But the gist of the code to get the counts looks like this:
function getSharesGoogleplus(el,href) {
// el => element to update
// href => url to check
$.ajax({
url: 'https://clients6.google.com/rpc',
type: 'post',
dataType: 'json',
contentType: 'application/json; charset=UTF-8',
data: JSON.stringify([ // request data must be a JSON ARRAY of HASHES
{
key: "<your google api key>", // replace with your API Key
method: "pos.plusones.get",
id: "p",
params:{
id: href, // URL to get +1's for
nolog: true,
source: "widget",
userId: "@viewer",
groupId: "@self"
},
jsonrpc:"2.0",
apiVersion:"v1"
}
])
}).done(function(data) {
if(data && data.length && data[0].metadata & data[0].metadata.globalCounts) {
$(el).text(data[0].metadata.globalCounts.count);
}
});
}
I'm building a site that will not have PHP support but would like the G+ button. Is there an alternative?
Great plugin btw :)