包信息
| 属性 | 值 |
|---|---|
| NuGet 包 | Bitzsoft.Integrations.Captcha.Tencent |
| Provider ID | tencent |
| 鉴权 | SecretId + SecretKey + CaptchaAppId(TC3-HMAC-SHA256) |
| 版本 | 天御 TCaptcha |
配置字段(TencentOptions)
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
SecretId | string | 是 | — | 腾讯云 SecretId |
SecretKey | string | 是 | — | 腾讯云 SecretKey |
CaptchaAppId | long | 是 | 0 | 验证码应用 CaptchaAppId |
AppSecretKey | string | 是 | — | 验证码应用 AppSecretKey |
Region | string | 否 | ap-guangzhou | 地域 |
Endpoint | string | 否 | captcha.tencentcloudapi.com | 验证码服务端点 |
ScriptUrl | string | 否 | 腾讯 CDN | 前端 SDK 脚本地址 |
Timeout | TimeSpan | 否 | 30s | HTTP 请求超时 |
HttpClientName | string | 否 | TencentCaptchaProvider | 命名 HttpClient |
配置示例
{ "Captcha": { "Tencent": { "SecretId": "AKIDxxxxxxxx", "SecretKey": "your-secret-key", "CaptchaAppId": 1234567890, "AppSecretKey": "your-app-secret-key" } }}DI 注册
builder.Services.AddBitzsoftTencentCaptcha(builder.Configuration.GetSection("Captcha:Tencent"));使用示例
public class TencentCaptchaService(ICaptchaProvider captcha){ public async Task<CaptchaResult<CaptchaVerification>> VerifyAsync(string ticket, string randstr, string userIp) { return await captcha.VerifyAsync(new CaptchaVerifyRequest { Ticket = ticket, Randstr = randstr, UserIp = userIp, }); }}已知限制
AppSecretKey是验证码应用的密钥(在腾讯云验证码控制台获取),与SecretKey是不同的密钥。CaptchaAppId为long类型(非 string)。
相关
- 验证码域手册(如有)