Method: FbRuby::Comments#get_react
- Defined in:
- lib/FbRuby/comments.rb
#get_react ⇒ Object
Mendapatkan jumblah react yang di berikan terhadap komentar ini
@return mengembalikan Hash yang memuat informasi jenis react dan jumblah react
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/FbRuby/comments.rb', line 158 def get_react reactData = {} FbRuby::Posts.REACT_LIST.each{|i| reactData[i] = 0} ufi = @html.at_css("a[href^='/ufi/reaction/profile']") unless ufi.nil? html = @sessions.get(URI.join(@url, ufi['href'])).parse_html reactUrl = html.xpath("//a[starts-with(@href,'/ufi/reaction/profile') and contains(@href,'total_count') and contains(@href,'reaction_type')]") reactUrl.each do |f| total = (f['href'].match(/total_count=(\d+)/)[1]).to_i type = f['href'].match(/reaction_type=(\d+)/)[1] next unless FbRuby::Posts.REACT_TYPE.include?(type) reactData[FbRuby::Posts.REACT_TYPE[type]] = total end end return reactData end |