module Line::Timeline::Api
Constants
- VERSION
Public Class Methods
get_home_id(session)
click to toggle source
# File lib/line/timeline/api.rb, line 10 def self.get_home_id(session) url = URI.parse'https://timeline.line.me/' http = Net::HTTP.new url.host, url.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new url.path request['cookie'] = session response = http.request(request) body = response.body user_id = body.scan(/href="\/user\/([^"]+)" data-reactid="\d+">Home/) if user_id.empty? nil else user_id[0][0] end end
get_user_feed(cookie, home_id, next_scroll_id = nil, post_limit=10, comment_limit=2, like_limit=20)
click to toggle source
# File lib/line/timeline/api.rb, line 27 def self.get_user_feed (cookie, home_id, next_scroll_id = nil, post_limit=10, comment_limit=2, like_limit=20) url_string = "https://timeline.line.me/api/post/list.json?homeId=#{home_id}&postLimit=#{post_limit}&commentLimit=#{comment_limit}&likeLimit=#{like_limit}&requestTime=" + DateTime.now.strftime('%Q') url_string += '&scrollId=' + next_scroll_id unless next_scroll_id.nil? url = URI.parse(url_string) http = Net::HTTP.new url.host, url.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new url.path + '?' + url.query request['X-Timeline-WebVersion'] = '1.9.2' request['X-Line-AcceptLanguage'] = 'en' request['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' request['Accept'] = 'application/json, text/plain, */*' request['Connection'] = 'keep-alive' request['cookie'] = cookie request['Referer'] = 'https://timeline.line.me/' + cookie.scan(/trmcpage=([^;]+)/)[0][0] response = http.request(request) JSON.parse response.body end