[英]Get twitter and google plus share count or any alternate
Hi I have tried below code for twitter.嗨,我已经尝试过下面的 twitter 代码。
var tw_share_count = 0;
TWUrl = "https://cdn.api.twitter.com/1/urls/count.json?url=" + url + '&callback=?'
$.ajax({
type: 'GET',
url: TWUrl,
success: function (data) {
tw_share_count = data.count.toString();
alert(tw_share_count);
},
async: false
});
And below code for google share count下面是谷歌共享计数的代码
var gl_shares_count = 0; var gl_shares_count = 0;
$.ajax({
type: 'POST',
url: 'https://apis.google.com/js/platform.js',
processData: true,
contentType: 'application/json',
data: JSON.stringify({
'method': 'pos.plusones.get',
'id': url,
'params': {
'nolog': true,
'id': url,
'source': 'widget',
'userId': '@viewer',
'groupId': '@self'
},
'jsonrpc': '2.0',
'key': 'p',
'apiVersion': 'v1'
}),
success: function (response) {
alert(response.result.metadata.globalCounts.count);
// $('a.googleplus .counter').text(response.result.metadata.globalCounts.count);
}
});
In had checked in some of the sight and they are saying that both twitter and google + has stopped sharing count.在检查了一些视线,他们说 twitter 和 google + 都已停止共享计数。 I dont know how much it is true.
我不知道有多少是真的。
I am able to share the link but not able to have count.我能够分享链接,但无法计数。 My Facebook and Pinterest count is coming very well but twitter and google plus count is not coming
我的 Facebook 和 Pinterest 数量正在增长,但 twitter 和 google plus 数量没有来
Please get me rid of this issue or give me the alternate for this that is easy and free to implement.请让我摆脱这个问题,或者给我一个容易且免费实施的替代方案。
For test I am using some random site to get the exact data for twitter/ google+ count like https://draxe.com/emotions-lower-inflammation/为了进行测试,我正在使用一些随机站点来获取 twitter/google+ 计数的确切数据,例如https://draxe.com/emotions-lower-inflammation/
take a look at this, i got a third party js to get social count.看看这个,我有一个第三方 js 来获得社交计数。 May be this will help you
可能这会帮助你
<!doctype html> <html lang="ja"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://webcyou.github.io/social-share-count-js/js/social-share-count.js"></script> <title>Share Count</title> <style> .fa { padding: 20px; font-size: 30px; width: 50px; text-align: center; text-decoration: none; margin: 5px 2px; } .fa:hover { opacity: 0.7; } .fa-facebook { background: #3B5998; color: white; } .fa-twitter { background: #55ACEE; color: white; } .fa-google { background: #dd4b39; color: white; } .fa-linkedin { background: #007bb5; color: white; } .fa-pinterest { background: #cb2027; color: white; } .fa-yahoo { background: #430297; color: white; } p{ font-size:14px; } </style> </head> <body> <a href="#" class="fa fa-facebook"> <p data-sc-fb="http://www.eventbee.com"></p> </a> <a href="#" class="fa fa-twitter"> <p data-sc-tw="https://stackoverflow.com"></p> </a> <a href="#" class="fa fa-google"> <p data-sc-gp="http://www.webcyou.com"></p> </a> <a href="#" class="fa fa-pinterest"> <p data-sc-pr="https://www.google.com/"></p> </a> <a href="#" class="fa fa-linkedin"> <p data-sc-ln="https://www.yahoo.com/"></p> </a> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.