Method: FbRuby::Comments#send_react

Defined in:
lib/FbRuby/comments.rb

#send_react(react_type) ⇒ Boolean

Berikan Reaksi Ke Komentar

List reaksi yang bisa di gunakan

  • like

  • love

  • care

  • haha

  • wow

  • sad

  • angry

Parameters:

  • react_type (String)

    Jenis Reaksi

Returns:

  • (Boolean)

Raises:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/FbRuby/comments.rb', line 117

def send_react(react_type)
  react_type.downcase!
  react_list = FbRuby::Posts.REACT_LIST
  react_url = @html.at_css("a[href^='/reactions/picker']")
  raise FbRuby::Exceptions::FacebookError.new("Invalid React Type!!!") if !react_list.include?(react_type)
  raise FbRuby::Exceptions::FacebookError.new("Tidak dapat memberikan react ke komentar ini:(") if react_url.nil?
  html = @sessions.get(URI.join(@url, react_url['href'])).parse_html
  react = html.xpath("//a[starts-with(@href,'/ufi/reaction')]")

  begin      
    send = @sessions.get_without_sessions(URI.join(@url,react[react_list.index(react_type)]['href']))
    return send.ok?
  rescue RestClient::NotFound
    return true
  end
end