腾讯防水墙验证码?

  • 回答 (1)
  • 关注 (0)
  • 查看 (51)

按照文档流程走完之后,接口报user code len error验证码长度不匹配uin no match号码不匹配

这个错误是什么原因呢

用户1376163用户1376163提问于
用户3932154回答于

$time=time();

$Nonce=rand(1,9999999);

$Action='DescribeCaptchaResult';

$Version='2019-07-22';

$Randstr=md5(uniqid(microtime(true),true));

$AppSecretKey='0iIQEb67*********GcLHtw**a';

$CaptchaAppId='2075**6928';

$SecretId='AKIDxiFXXKu*******LvHH5f182h8kH0U';

$secretKey='PaVBe7OozN**********agYCbmiPt9B6mD';

$param["Nonce"] = $Nonce;

$param["Timestamp"] = $time;

// $param["Region"] = "ap-chongqing";

$param["SecretId"] = $SecretId;

$param["Action"] = $Action;

$param["Version"] = $Version;

$param["CaptchaType"] = "9";

$param["Ticket"] = $ticket;

$param["UserIp"] = $ip;

$param["Randstr"] = $Randstr;

ksort($param);

$signStr = "GETcaptcha.tencentcloudapi.com/?";

foreach ( $param as $key => $value ) {

$signStr = $signStr . $key . "=" . $value . "&";

}

$signStr = substr($signStr, 0, -1);

$signature = base64_encode(hash_hmac("sha1", $signStr,$secretKey, true));

$signature=urlencode($signature);

$post_data = array(

'Action' => $Action,

'AppSecretKey' =>$AppSecretKey,

'CaptchaType' =>'9',

'CaptchaAppId' =>$CaptchaAppId,

'Nonce' =>$Nonce,

'Randstr' =>$Randstr,

'SecretId'=>$SecretId,

'Signature'=>$signature,

'Ticket' =>$ticket,

'Timestamp' =>$time,

'UserIp' =>$ip,

'Version' =>$Version,

);

$url='https://captcha.tencentcloudapi.com/';

$query = http_build_query($post_data);

$result = file_get_contents($url.'?'.$query);

$arr=json_decode($result,true);

返回的结果老是提示签名错误,请问哪里错误了

{"Response":{"Error":{"Code":"AuthFailure.SignatureFailure","Message":"The provided credentials could not be validated. Please check your signature is correct."},"RequestId":"1a44927c-f79d-480d-b294-41fedd331a92"}}

扫码关注云+社区

领取腾讯云代金券