TencentCaptcha


 腾讯云的验证码控制台:验证码-图形验证https://console.cloud.tencent.com/captcha/graphicalhttps://console.cloud.tencent.com/captcha/graphical

前端接入文档:绑定一个元素并手动传入场景Id和回调

 new TencentCaptcha(element, CaptchaAppId, callback, options);

try { 
  new TencentCaptcha(
    document.getElementById('TencentCaptcha'),
    'CaptchaAppId',
    callback,
    { bizState: '自定义透传参数' },    // (可选) 业务自定义透传参数, 会在回调函数内获取到 (res.bizState)
  );
} catch (error) {
  loadErrorCallback();
}

function callback(res) {
  /* res(验证成功) = {ret: 0, ticket: "String", randstr: "String"}
     res(客户端出现异常错误 仍返回可用票据) = {ret: 0, ticket: "String", randstr: "String", errorCode: Number, errorMessage: "String"}
     res(用户主动关闭验证码)= {ret: 2}
  */
  if (res.ticket){
    // 上传票据 可根据errorCode和errorMessage做特殊处理或统计
  }
}

 {
    "bizState":"test",
    "appid":"2093541830",
    "ret":0,
    "ticket":"t03FexlZVDcQNgy-yz8JTuib4sjI-dagr6DVCsjzMbKtCqnf0M…8hcj-gm5tjZmogOa9FeIUiQwPkLUeRsYhYGbD2Ga2U86gPg**",
    "randstr":"@foo"
}


 快速入门:

 


后端:

后端接入文档https://packagist.org/packages/tencentcloud/tencentcloud-sdk-phphttps://packagist.org/packages/tencentcloud/tencentcloud-sdk-php

 申请安全凭证: API密钥管理https://console.cloud.tencent.com/cam/capihttps://console.cloud.tencent.com/cam/capi

 

<?php
require_once './tencentcloud-sdk-php/vendor/autoload.php';
use TencentCloud\Common\Credential;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Captcha\V20190722\CaptchaClient;
use TencentCloud\Captcha\V20190722\Models\DescribeCaptchaResultRequest;
try {

    $cred = new Credential("AKIDYu1sSloa4HGyPZT6UdV6QTGo79uOcaHh", "B5i4AzXooZ4HDtJn0xf5E8m9F5fy0nLd");
    $httpProfile = new HttpProfile();
    $httpProfile->setEndpoint("captcha.tencentcloudapi.com");

    $clientProfile = new ClientProfile();
    $clientProfile->setHttpProfile($httpProfile);
    $client = new CaptchaClient($cred, "", $clientProfile);

    $req = new DescribeCaptchaResultRequest();

    $params = array(
        "CaptchaType" => 19,
        "Ticket" => "t03RNWg-CjuUelYLsjE2O05ebPvHFtqFpLuFwwMQ-35SMo-z0ti6lnix6NMj5Cj_CEBbCcYw9cS7rrYzohK2sdgEhWK5pfpSzsdJ6jAhAplJU0*",
        "UserIp" => "1.192.215.34",
        "Randstr" => "@GwG",
        "CaptchaAppId" => 2093541830,
        "AppSecretKey" => "0wJ31ytnuZPY9E0tQlqkodQ**"
    );
    $req->fromJsonString(json_encode($params));

    $resp = $client->DescribeCaptchaResult($req);

    print_r($resp->toJsonString());
}
catch(TencentCloudSDKException $e) {
    echo $e;
}

 结果:

{
    "CaptchaCode":1,
    "CaptchaMsg":"OK",
    "EvilLevel":0,
    "GetCaptchaTime":0,
    "RequestId":"9b291117-f081-4f1c-b1d8-e1beb2e91cad"
}

API Explorer - 在线调用https://console.cloud.tencent.com/api/explorer?Product=captchahttps://console.cloud.tencent.com/api/explorer?Product=captcha

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值