获取Google Plus Url Share Count

时间:2015-03-12 17:36:54

标签: google-plus share

我已阅读大量有关如何执行此操作的帖子,他们都说要使用:

gapi.client.setApiKey('AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ')
gapi.client.rpcRequest('pos.plusones.get', 'v1', {
   nolog: true,
   id: "http://www.google.com/",
   source: "widget",
   userId: "@viewer",
   groupId: "@self"
}).execute(function(resp) {
   console.log('count:', resp.result.metadata.globalCounts.count)
});

rpcRequest似乎不再支持接受的调用是.request但是当使用pos.plusone.get时它只是404的。是否有其他URL可供使用?这是不可能的。给了什么?

1 个答案:

答案 0 :(得分:0)

这对我来说仍然有效:

<强> HTML

<script src="https://apis.google.com/js/plusone.js"></script>
<script src="https://apis.google.com/js/client:plusone.js"></script>

<强> JS

var params = {
  nolog: true,
  id: "http://www.google.com/",
  source: "widget",
  userId: "@viewer",
  groupId: "@self"
};

gapi.client.setApiKey('AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ')
gapi.client.rpcRequest('pos.plusones.get', 'v1', params).execute(function(resp) {
  console.log('count:', resp.result.metadata.globalCounts.count)
});

JSF:http://jsfiddle.net/rs7z5aLc/

此外,您将收到以下警告:

gapi.client.rpcRequest is deprecated. See https://developers.google.com/api-client-library/javascript/reference/referencedocs

所以这可能只是时间问题。

相关问题