Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
刘志永 committed Sep 2, 2021
1 parent 8aca2cf commit 04854e2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kernel/python/kernel/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.8'
__version__ = '1.0.9'
41 changes: 33 additions & 8 deletions kernel/python/kernel/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def read_as_json(self,teaResponse):

def sign(self,system_params,biz_params,text_params,secret_key):
mergeDic = merge(system_params,biz_params,text_params)
sorted_map = sort_map(mergeDic)
encodeStr = urlencode(sorted_map,'utf-8')
# sorted_map = sort_map(mergeDic)
encodeStr = self.build_query_string(mergeDic)
encodeStr = encodeStr.replace('+','')
x = hashlib.sha256()
x.update((secret_key + encodeStr).encode('utf-8'))
Expand All @@ -65,11 +65,19 @@ def to_resp_model(self,params):
return json.loads(data)
raise Exception('接口访问异常,code:{},msg:{}'.format(code,msg))
def to_url_encoded_request_body(self,params):
sorted_map = sort_map(params)
return self.build_query_string(sorted_map)
# sorted_map = sort_map(params)
return self.build_query_string(params)
def build_query_string(self,sorted_dict):
content = urlencode(sorted_dict,'utf-8')
return content
keys = []

for k in sorted_dict:
keys.append(k)
new_keys = sorted(keys)
pList = []
for i in new_keys :
pList.append(i+"="+sorted_dict[i])
requestUrl = '&'.join(pList)
return requestUrl
if __name__ == '__main__':
config = Config()
config.secretKey = '111'
Expand Down Expand Up @@ -107,10 +115,12 @@ def build_query_string(self,sorted_dict):
'app_id': '4139937041702170912',
'merchant_id': '87891',
'access_token': 'efd83327-63a9-4e03-b913-1accbcc549b6',
'timestamp': '1630500481740',
'timestamp': '1630547616151',
'version': '1.0',
'business_data': '{\"page_no\": \"1\", \"page_size\": \"20\", \"merchant_id\": \"87891\"}'
}
map2 = {}
map3 = {}

# print(urlencode(sort_map(map),'utf-8'))
# client.sort_map(params)
Expand All @@ -120,5 +130,20 @@ def build_query_string(self,sorted_dict):
# print(r.decode('utf-8'))
# content = client.build_query_string(params)
# print(urlencode(params))
dic4 = client.sign(dic1,dic2,dic3,"123456")
my_params = {
'page_no':'1',
'page_size': '20',
'merchant_id':'87891'

}
system_params = {
'app_id': '4139937041702170912',
'merchant_id':'87891',
'access_token': 'efd83327-63a9-4e03-b913-1accbcc549b6',
'timestamp': '1630547616151',
'version': '1.0',
'business_data': json.dumps(my_params).replace(' ','')
}
# content = client.build_query_string(system_params);
dic4 = client.sign(system_params,map2,map3,"3badb149-67df-462e-9c57-683016d0a5d3")
print(dic4)
2 changes: 1 addition & 1 deletion kernel/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
AUTHOR_EMAIL = "alibaba-cloud-sdk-dev-team@list.alibaba-inc.com"
URL = "https://github.com/eleme/anubis-openapi-third/tree/main/kernel/python"
TOPDIR = os.path.dirname(__file__) or "."
VERSION = "1.0.8"
VERSION = "1.0.9"

with open("README.md", encoding="utf-8") as fp:
LONG_DESCRIPTION = fp.read()
Expand Down

0 comments on commit 04854e2

Please sign in to comment.