腾讯云“人脸静态活体检测”api怎么请求?

###########鉴权代码######################

#鉴权签名
appid=''
bucket = ''
SecretID = ''
secret_key = ''
expiredTime = time.time()+2592000
currentTime = time.time()
rand = round(random.random()*(10**8))
userid = "0"
#资源存储的唯一标识,单次签名必填;多次签名选填,如填写则会验证与当前操作的文件路径是否一致。
fileid = 'xuehua.jpg'
req = "a=[{appid}]&b=[{bucket}]&k=[{SecretID}]&e=[{expiredTime}]&t=[{currentTime}]&r=[{rand}]&u=[{userid}]&f=[{fileid}]".format(appid=appid,bucket=bucket,SecretID=SecretID,expiredTime=expiredTime,currentTime=currentTime,rand=rand,userid=userid,fileid=fileid)
req = bytes(req,'utf8')
secret_key = bytes(secret_key,'utf8')
sha = hmac.new(secret_key,req,digestmod=hashlib.sha1)
encrypts = sha.digest()
print(encrypts)
sign = base64.b64encode(encrypts)
print(sign)

结果

https://img.mukewang.com/5ab76ad40001c07904050055.jpg

####################请求静态活体检测api########################

url_livedetectpicture = 'http://service.image.myqcloud.com/face/livedetectpicture'
header = {'Authorization':sign,"content-type":"application/json"}
data = {'appid':appid,"sign":'123456',"url":"http://compuspro-*********.coscd.myqcloud.com/advertising/2017/12/07/bear_three.png"}
r = requests.post(url_livedetectpicture,data = data,params=header)
print(r.text)

结果

{"code":3,"message":"invalid request: parsing error - check content-type and body","data":{}}

网上资料也不多,希望能请教到大神或有经验的朋友,这个请求该怎么改

无无法师
浏览 2106回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP