Class: Eurus::Weibo

Inherits:
Object
  • Object
show all
Defined in:
lib/eurus-weibo-commercial.rb

Overview

Your code goes here…

Instance Method Summary collapse

Constructor Details

#initialize(appkey = "", subid = "") ⇒ Weibo



10
11
12
13
# File 'lib/eurus-weibo-commercial.rb', line 10

def initialize(appkey="", subid="")
  @appkey = appkey
  @subid = subid
end

Instance Method Details

#infoObject



15
16
17
18
# File 'lib/eurus-weibo-commercial.rb', line 15

def info
  ap "appkey: #{@appkey}"
  ap "subid: #{@subid}"
end

#update_subscribe(opt = "", stuff = "") ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/eurus-weibo-commercial.rb', line 20

def update_subscribe(opt="", stuff="")
  # precheck if appkey and subid exist
  if @appkey == "" or @subid == ""
    raise "appkey or subid missing"
  else
    url = URI "https://c.api.weibo.com/subscribe/update_subscribe.json"
    res = Net::HTTP.post_form(url,
                              source: @appkey,
                              subid: @subid,
                              "#{opt}": "#{stuff}")
    res_obj = JSON.parse res.body
    return res_obj
  end
end