Last active
January 24, 2019 13:22
-
-
Save kelby/b38ecda2c16948a16e80d1b994e38a29 to your computer and use it in GitHub Desktop.
StocksExchange API Integration
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
require 'openssl' | |
require 'httparty' | |
url = "https://stocks.exchange/api2" | |
api_key = "your_api_key" | |
api_secret = "your_api_secret" | |
nonce = Time.now.to_i | |
method = "GetInfo" | |
data = {"method": method, "nonce": nonce} | |
signdata = "method=#{method}&nonce=#{nonce}" | |
sign = OpenSSL::HMAC.hexdigest("SHA512", api_secret, signdata) | |
response = HTTParty.post(url, | |
:body => data.to_json, | |
:headers => { 'Sign' => sign, 'Key' => api_key }) |
# base url is changed. use this:
url = "https://app.stex.com/api2?method=#{method}&nonce=#{nonce}"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your code not correct working.
Please checked this code