Skip to content

Instantly share code, notes, and snippets.

@dancsiqueira
Created August 27, 2013 13:30
Show Gist options
  • Select an option

  • Save dancsiqueira/6353534 to your computer and use it in GitHub Desktop.

Select an option

Save dancsiqueira/6353534 to your computer and use it in GitHub Desktop.
def plusone_counter(url)
client = "https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ"
parameters = "[{ 'method':'pos.plusones.get', 'id':'p', 'params':{ 'nolog':true, 'id':'#{ url }', 'source':'widget', 'userId':'@viewer', 'groupId':'@self' }, 'jsonrpc':'2.0', 'key':'p', 'apiVersion':'v1' }]"
rest_response = RestClient.post(client, parameters, content_type: :json)
result = JSON.parse(rest_response)
result[0]['result']['metadata']['globalCounts']['count']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment