Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. from time import time
  2. import urllib.request
  3. import urllib.parse
  4. import hashlib
  5. import hmac
  6.  
  7. APIkey = b'provert-key'
  8. secret = b'ceeeecret'
  9. url = 'https://poloniex.com/tradingApi'
  10.  
  11. payload = {
  12. 'command': 'returnBalances',
  13. 'nonce': int(time() * 1000),
  14. }
  15.  
  16. paybytes = urllib.parse.urlencode(payload).encode('utf8')
  17. print(paybytes)
  18.  
  19. sign = hmac.new(secret, paybytes, hashlib.sha512).hexdigest()
  20. print(sign)
  21.  
  22. headers = {
  23. 'Key': APIkey,
  24. 'Sign': sign,
  25. }
  26.  
  27. req = urllib.request.Request(url, headers=headers, data=paybytes)
  28. with urllib.request.urlopen(req) as response:
  29. the_page = response.read()
  30. print(the_page)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement