Last active
June 8, 2017 10:01
-
-
Save muhammadyana/c6eb7900b4f6be91976af2c001dca006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #thursday-08-2017 | |
| #@41studio | |
| #Muhammad Yana Mulyana | |
| #regex in ruby | |
| # require 'net/http' | |
| # image = Net::HTTP.get_response(URI.parse("http://www.indoexchanger.co.id/private/rest/indoExchanger/amountBitcoin")).body | |
| # | |
| # puts image | |
| # require 'open-uri' | |
| # | |
| # file = open("https://indoexchanger.co.id/private/rest/indoExchanger/amountBitcoin") | |
| # | |
| # document = open('https://indoexchanger.co.id/private/rest/indoExchanger/amountBitcoin').read | |
| # | |
| # d = JSON.parse document | |
| # | |
| # data = JSON.parse file.read | |
| # | |
| # puts d | |
| puts "Usernmae " | |
| username = gets.chomp.to_s | |
| puts "password " | |
| password = gets.chomp.to_s | |
| require 'uri' | |
| require 'net/http' | |
| class ParsingJson | |
| def initialize(username, password) | |
| @Username = username | |
| @Password = password | |
| end | |
| def amountBTC | |
| url = URI("https://indoexchanger.co.id/private/rest/indoExchanger/amountBitcoin") | |
| http = Net::HTTP.new(url.host, url.port) | |
| http.use_ssl = true | |
| request = Net::HTTP::Post.new(url) | |
| request["content-type"] = 'application/x-www-form-urlencoded' | |
| request["cache-control"] = 'no-cache' | |
| response = http.request(request) | |
| return response.read_body | |
| end | |
| def Login(username, password) | |
| url = URI("http://indoexchanger.co.id/private/rest/authentication/authenticateCustomerPost") | |
| http = Net::HTTP.new(url.host, url.port) | |
| request = Net::HTTP::Post.new(url) | |
| request["content-type"] = 'application/x-www-form-urlencoded' | |
| request["cache-control"] = 'no-cache' | |
| request.body = "json=%7B%7D&username=#{@Username}&password=#{@Password}" | |
| response = http.request(request) | |
| return response.read_body | |
| end | |
| end | |
| class Json < ParsingJson | |
| end | |
| #puts Json | |
| #jsn = Json.new | |
| #puts jsn.urls | |
| js = ParsingJson.new(username, password) | |
| #p js | |
| tmp = js.Login(username, password) | |
| puts tmp | |
| #puts tmp.object_id['sessionId'] | |
| # amount = ParsingJson.new | |
| p js.amountBTC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment