Created
December 11, 2018 11:20
-
-
Save seandong/427524818bc5ffbaafc61e57a9278d7d to your computer and use it in GitHub Desktop.
zhiren API demo
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf8 -*- | |
import hmac | |
import hashlib | |
import json | |
import time | |
import urllib | |
import requests | |
access_key = 'xxx' | |
secret_key = 'xxx' | |
#payload = '' | |
tonce = time.time() | |
string_to_sign = 'GET' + '/api/v2/sub_companies' + access_key + str(tonce)# + json.dumps(payload) | |
signature = hmac.new(secret_key, string_to_sign, hashlib.sha256).hexdigest() | |
params = {'access_key': access_key, 'tonce': tonce, 'payload': ''} | |
headers = {'x-zhiren-signature': signature} | |
r = requests.get('https://zhiren.com/api/v2/sub_companies', params=urllib.urlencode(params), headers=headers) | |
print r.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment