|
@@ -9,6 +9,7 @@ import random
|
|
|
import string
|
|
|
import time
|
|
|
import requests
|
|
|
+from collections import OrderedDict
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
@@ -52,15 +53,16 @@ class UVerifyObject:
|
|
|
value = sign_headers_dict[key]
|
|
|
sign_headers_str = sign_headers_str + key + ':' + value + '\n'
|
|
|
|
|
|
- sign_dict = {
|
|
|
- 'HTTPMethod': 'POST',
|
|
|
- 'Accept': 'application/json',
|
|
|
- 'Content-MD5': content_md5_str,
|
|
|
- 'Content-Type': 'application/json; charset=UTF-8',
|
|
|
- 'Date': None,
|
|
|
- 'Headers': sign_headers_str,
|
|
|
- 'Url': self.path_url + '?' + 'appkey=' + self.umeng_app_key,
|
|
|
- }
|
|
|
+ # 需要使用有序字典,否则StringToSign错误
|
|
|
+ sign_dict = OrderedDict(
|
|
|
+ [('HTTPMethod', 'POST'),
|
|
|
+ ('Accept', 'application/json'),
|
|
|
+ ('Content-MD5', content_md5_str),
|
|
|
+ ('Content-Type', 'application/json; charset=UTF-8'),
|
|
|
+ ('Date', None,),
|
|
|
+ ('Headers', sign_headers_str),
|
|
|
+ ('Url', self.path_url + '?' + 'appkey=' + self.umeng_app_key)]
|
|
|
+ )
|
|
|
|
|
|
string_to_sign = ""
|
|
|
for key in sign_dict.keys():
|