require 'net/https'
require 'kconv'
require 'openssl'
APPKEY='xxfvFQcOzpTBvwuwPMwwzLZxiCSaGb'
HMKEY='DgQ3aNpoluV1cl3GFJAqitBg5xKiXZ'
def authenticate()
http = Net::HTTP.new('api.2ch.net', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
path = '/v1/auth/'
data ={:ID=>'', :PW=>'', :KY=>APPKEY, :CT=>'',:HB=>''}
headers = {
'User-Agent' => '',
'X-2ch-UA' => 'JaneStyle/3.80'
}
res=http.post(path, URI.encode_www_form(data), headers)
sid=res.body.split(':')[1]
return sid
end
def getDAT(serverName,boardName,threadId,sid)
http = Net::HTTP.new('api.2ch.net', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
path="/v1/#{serverName}/#{boardName}/#{threadId}"
message = "#{path}#{sid}#{APPKEY}"
hobo=OpenSSL::HMAC::hexdigest(OpenSSL::Digest::SHA256.new, HMKEY, message)
data="sid=#{sid}&hobo=#{hobo}&appkey=#{APPKEY}"
headers = {
'User-Agent' =>'Mozilla/3.0 (compatible; JaneStyle/3.80..)'
}
res=http.post(path, data, headers)
return res.body.toutf8
end
sid=authenticate()
dat=getDAT('anago','software','1424327586',sid)
p dat