Class: ShareCount::Weibo

Inherits:
Base
  • Object
show all
Defined in:
lib/share_count/weibo.rb

Constant Summary collapse

URL_FOR_SHORT =
'https://api.weibo.com/2/short_url/shorten.json'
URL_FOR_SHARE =
'https://api.weibo.com/2/short_url/share/counts.json'

Constants inherited from Base

Base::DEFAULT_OPEN_TIMEOUT, Base::DEFAULT_TIMEOUT

Instance Attribute Summary

Attributes inherited from Base

#checked_url

Instance Method Summary collapse

Methods inherited from Base

config=, #initialize, #shares

Methods included from StringHelper

#to_camel_case, #to_underscore

Constructor Details

This class inherits a constructor from ShareCount::Base

Instance Method Details

#shares!Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/share_count/weibo.rb', line 6

def shares!
  response = get(URL_FOR_SHARE, {
    params: {
      _: '1414437609900',
      source: '8003029170',
      url_short: short_url
    }
  })

  JSON.parse(response)['urls'].first['share_counts'].to_i
end