$.ajax({
type: 'POST',
url: 'https://clients6.google.com/rpc',
processData: true,
contentType: 'application/json',
data: JSON.stringify({
'method': 'pos.plusones.get',
'id': location.href,
'params': {
'nolog': true,
'id': location.href,
'source': 'widget',
'userId': '@viewer',
'groupId': '@self'
},
'jsonrpc': '2.0',
'key': 'p',
'apiVersion': 'v1'
}),
success: function(response) {
$('[data-counter="googleplus"]').text(response.result.metadata.globalCounts.count);
}
});
.match()
добыть нужное значение. Вот пример кода: https://github.com/koddr/goodshare.js/blob/master/... $.getJSON('https://api.tumblr.com/v2/share/stats?url=' + encodeURIComponent(location.href) + '&callback=?', function(response) {
$('[data-counter="tumblr"]').text(response.response.note_count);
});
import 'whatwg-fetch';
import { Vkontakte } from './providers/Vkontakte';
let vk_count = new Vkontakte().getCounter();
console.log(vk_count);
getCounter() {
let api = 'https://vk.com/share.php?act=count&index=1&url=' + encodeURIComponent(this.url);
return fetch(api, {method: 'GET', mode: 'cors'})
.then(this.checkStatus)
.then(function (response) {
return response.text();
})
.then(function (count) {
return count.match(/^VK\.Share\.count\(\d, (\d+)\);$/)[1] / 1;
})
.catch(function (error) {
console.log('Request failed!', error);
});
}
getCounter() {
let api = 'https://vk.com/share.php?act=count&index=1&url=' + encodeURIComponent(this.url);
return fetch(api, {mode: 'cors'})
.then(
function (response) {
if (response.status !== 200) {
console.log('Status code: ' + response.status);
return;
}
response.text()
.then(
function (count) {
return count.match(/^VK\.Share\.count\(\d, (\d+)\);$/)[1] / 1;
}
)
}
)
.catch(function (error) {
console.log('Request failed: ' + error);
});
}
При этом, если физически запустить сервер из консоли (например, повесить на IP сервера и 8000 порт), то сайт начинает работать. Тем самым давая понять, что gunicorn работает.