[英]how to get the +1 count in google plus using any API
我尝试了很多东西,但是我无法获得一个合适的API,它会在google plus中返回+1计数。
我已经尝试过使用: -
通过Jquery和AJAX获取Twitter链接,Facebook喜欢和Google +1的计数
但他们都没有给我答案。
有什么想法吗....
谢谢 :)
我刚刚发现了一个非常有用的网站来解决我们的问题。 :)谢谢他! http://99webtools.com/script-to-get-shared-count.php
您可以使用jgillich提到的链接编写自己的函数。 使用jQuery稍微简化一下。
这是我作为一个例子的jsfiddle 。 如果你想绕过域间问题,你可能不得不使用像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+信息的其他方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.