10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/social_butterfly/services/google_plus_service.rb', line 10
def self.track(content, service_options={})
stats = {}
jsonstring = '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' + content[:url] +'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]'
c = Curl::Easy.http_post("https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ", jsonstring) do |curl|
curl.['Accept'] = 'application/json'
curl.['Content-Type'] = 'application/json'
curl.['Api-Version'] = '2.2'
end
response = JSON.parse(c.body_str)
if !response[0].present? || response[0]['error'].present?
stats[:shares] = 0
else
stats[:shares] = response[0]['result']['metadata']['globalCounts']['count'].round
end
stats
end
|