我知道,如何用PHP制作G +计数器.我也知道使用Google API密钥的相同解决方案.
但是我尝试在我的jQuery插件中创建它(没有任何PHP类或其他东西)并且没有结果..
请帮助您提供示例代码.
Pla*_*ton 10
这个解决方案对我有用:
var uri = 'http://your-site.com';
$.ajax({
type: 'POST',
url: 'https://clients6.google.com/rpc',
processData: true,
contentType: 'application/json',
data: JSON.stringify({
'method': 'pos.plusones.get',
'id': uri,
'params': {
'nolog': true,
'id': uri,
'source': 'widget',
'userId': '@viewer',
'groupId': '@self'
},
'jsonrpc': '2.0',
'key': 'p',
'apiVersion': 'v1'
}),
success: function(response) {
$('a.googleplus .counter').text(response.result.metadata.globalCounts.count);
}
});
Run Code Online (Sandbox Code Playgroud)