[英]Displaying a List of Data from in Flask REST API Python
[英]Mintegral Data Migration from REST API in Python
Mintegral REST API document https://www.mintegral.com/wp-content/uploads/2018/10/1-Mintegral_Reporting-API.pdf
当我在 Python 中运行此代码时,它总是返回{"code":400,"msg":"Validation fails (Token Error)","data":null}
(附截图)
API 密钥和用户名正确。 不知道为什么????
import requests
import time
import hashlib
apikey = "xxxx"
encoded_timestamp = hashlib.md5(str(time.time()).encode())
token = apikey + encoded_timestamp.hexdigest()
md5_token = hashlib.md5(token.encode()).hexdigest()
response = requests.get("http://data.mintegral.com/v4.php?m=advertiser",
params = {
'username':'XXXABC'
,'token':md5_token
,'timestamp':str(int(time.time()))
# ,'utc':'+8'
,'start_date':'2022-06-07'
,'end_date':'2022-06-13'
,'Content-type': 'application/json'
# ,'per_page':5000
}
)
response.text
但是当我检查 PHP 中的示例时,它可以工作。 您能帮我修复 Python 代码吗? 有人有这方面的经验吗?
提前非常感谢!
看起来,您忘记在第 6 行创建 str(int(time.time()))
顺便说一句,问题出在逻辑上。 您使用 time.time() function 两次,一次是在创建令牌时,第二次是在 POST 时。 因此,您的 hash 与服务器 hash 不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.