获取 Google 加上 Url 分享计数

Get Google Plus Url Share Count

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

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 可以用吗?这已经不可能了吗。什么给了?

这对我仍然有效:

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

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