{"id":17922712,"url":"https://github.com/overtrue/laravel-qcloud-captcha","last_synced_at":"2025-03-24T02:32:45.138Z","repository":{"id":45238016,"uuid":"380226089","full_name":"overtrue/laravel-qcloud-captcha","owner":"overtrue","description":"QCloud Captcha service validator for Laravel.","archived":false,"fork":false,"pushed_at":"2024-03-13T05:07:47.000Z","size":39,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T02:44:19.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/overtrue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["overtrue"]}},"created_at":"2021-06-25T12:08:14.000Z","updated_at":"2021-12-29T03:39:52.000Z","dependencies_parsed_at":"2024-10-28T20:40:37.725Z","dependency_job_id":"97698e2e-af45-460f-a72e-4a58cc587e96","html_url":"https://github.com/overtrue/laravel-qcloud-captcha","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":"0.15384615384615385","last_synced_commit":"e780c1ade76a44999ac1e475c0f43ce7e2fa01ca"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":"overtrue/laravel-package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Flaravel-qcloud-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Flaravel-qcloud-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Flaravel-qcloud-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Flaravel-qcloud-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overtrue","download_url":"https://codeload.github.com/overtrue/laravel-qcloud-captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245198767,"owners_count":20576439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T20:40:33.229Z","updated_at":"2025-03-24T02:32:44.825Z","avatar_url":"https://github.com/overtrue.png","language":"PHP","funding_links":["https://github.com/sponsors/overtrue"],"categories":[],"sub_categories":[],"readme":"Laravel Qcloud Captcha\n---\n\n[![CI](https://github.com/overtrue/laravel-qcloud-captcha/actions/workflows/ci.yml/badge.svg)](https://github.com/overtrue/laravel-qcloud-captcha/actions/workflows/ci.yml)\n[![Latest Stable Version](https://poser.pugx.org/overtrue/laravel-qcloud-captcha/v/stable.svg)](https://packagist.org/packages/overtrue/laravel-qcloud-captcha)\n[![Latest Unstable Version](https://poser.pugx.org/overtrue/laravel-qcloud-captcha/v/unstable.svg)](https://packagist.org/packages/overtrue/laravel-qcloud-captcha)\n[![Total Downloads](https://poser.pugx.org/overtrue/laravel-qcloud-captcha/downloads)](https://packagist.org/packages/overtrue/laravel-qcloud-captcha)\n[![License](https://poser.pugx.org/overtrue/laravel-qcloud-captcha/license)](https://packagist.org/packages/overtrue/laravel-qcloud-captcha)\n\n腾讯云验证码是为网页、App 及小程序开发者提供的安全验证服务，目前网页及 App 支持以 Web 前端接入、App 端接入（iOS 和 Android）方式接入验证码服务，小程序开发者可以使用 小程序插件接入\n方式接入验证码服务，基于腾讯多年的大数据积累和人工智能决策引擎，构建智能分级验证模型，最大程度保护业务安全的同时，提供更精细化的用户体验。\n\n- :book: [官方 API](https://cloud.tencent.com/document/product/1110/36334)\n\n[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)\n\n## Installing\n\n```shell\n$ composer require overtrue/laravel-qcloud-captcha -vvv\n```\n\n### Config\n\n请在 `config/services.php` 中配置以下内容：\n\n```php\n    //...\n    // 验证码服务\n    'captcha' =\u003e [\n        // 腾讯云 API 秘钥：SecretId，SecretKey\n        // https://console.cloud.tencent.com/cam/capi\n        'secret_id' =\u003e env('CAPTCHA_SECRET_ID'),\n        'secret_key' =\u003e env('CAPTCHA_SECRET_KEY'),\n        \n        // 验证码服务秘钥：CaptchaAppId，AppSecretKey\n        'app_id' =\u003e env('CAPTCHA_APP_ID'), \n        'app_secret_key' =\u003e env('CAPTCHA_APP_SECRET_KEY'),\n        \n        // 以下非必填\n        'channel' =\u003e  'web', // 渠道：web/miniapp，默认 web\n        'endpoint' =\u003e env('CAPTCHA_ENDPOINT'), // 默认: captcha.tencentcloudapi.com\n    ],\n```\n\n或者配置成多场景：\n\n```php\n    //...\n    // 验证码服务\n    'captcha' =\u003e [\n        // 默认 app 名称\n        'default' =\u003e 'login',\n        \n        // app 配置\n        'apps' =\u003e [\n            'login' =\u003e [\n                'secret_id' =\u003e env('CAPTCHA_LOGIN_SECRET_ID'),\n                'secret_key' =\u003e env('CAPTCHA_LOGIN_SECRET_KEY'),\n                'app_id' =\u003e env('CAPTCHA_LOGIN_APP_ID'), \n                'app_secret_key' =\u003e env('CAPTCHA_LOGIN_APP_SECRET_KEY'),\n            ],\n            'register' =\u003e [\n                'secret_id' =\u003e env('CAPTCHA_REGISTER_SECRET_ID'),\n                'secret_key' =\u003e env('CAPTCHA_REGISTER_SECRET_KEY'),\n                'app_id' =\u003e env('CAPTCHA_REGISTER_APP_ID'), \n                'app_secret_key' =\u003e env('CAPTCHA_REGISTER_APP_SECRET_KEY'),\n            ],\n            //...\n        ],\n    ],\n```\n\n## API\n\n### 获取检查结果\n\n调用对应 API 返回 ticket 校验结果，返回值结构请参考官方 API 文档。\n\n\u003e 接口请求频率限制：1000次/秒。\n\n```php\nuse Overtrue\\LaravelQcloudCaptcha\\Captcha;\n\narray Captcha::validate(string $ticket, ?string $app = null, ?string $nonce = null);\narray Captcha::validateWebTicket(string $ticket, ?string $app = null, ?string $nonce = null);\narray Captcha::validateMiniAppTicket(string $ticket, ?string $app = null);\n```\n\n验证失败将抛出以下异常：\n\n- `Overtrue\\LaravelQcloudCaptcha\\InvalidTicketException`\n  - `$ticket` - (string) 被检测的 ticket\n  - `$response` - (array) API 原始返回值\n\n## 使用表单校验规则\n\n```php\n$this-\u003evalidate($request, [\n\t'ticket' =\u003e 'required|captcha:randstr',\n\t'avatar' =\u003e 'required|url|ims',\n\t'description' =\u003e 'required|tms:strict',\n\t'logo_url' =\u003e 'required|url|ims:logo',\n]);\n```\n\n**规则参数**：\n\n**Web** 类型验证码校验时需要传入回调时的 **前端回调函数返回的随机字符串** 对应的表单名称，例如请求后端时使用 `randstr` 作为表单名称提交随机字符串：\n\n```php\n// 请求内容\n[\n    'ticket' =\u003e 'xxxxxxxxx',\n    'randstr' =\u003e 'xxxxxxxxx',\n],\n\n//1. 使用默认应用，并以请求中 `randstr` 作为随机字符串校验\n'ticket' =\u003e 'required|captcha:randstr', \n\n//2. 使用 `login` 应用，并以请求中 `randstr` 作为随机字符串校验\n'ticket' =\u003e 'required|captcha:login,randstr',\n```\n\n**小程序** 验证码没有随机字符串参数：\n\n```php\n// 请求内容\n[\n    'ticket' =\u003e 'xxxxxxxxx',\n],\n\n//1. 使用默认应用\n'ticket' =\u003e 'required|captcha', \n\n//2. 使用 `login` 应用\n'ticket' =\u003e 'required|captcha:login',\n```\n\n## :heart: Sponsor me \n\n[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue)\n\n如果你喜欢我的项目并想支持它，[点击这里 :heart:](https://github.com/sponsors/overtrue)\n\n## Project supported by JetBrains\n\nMany thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.\n\n[![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/overtrue)\n\n\n## Contributing\n\nYou can contribute in one of three ways:\n\n1. File bug reports using the [issue tracker](https://github.com/overtrue/laravel-package/issues).\n2. Answer questions or fix bugs on the [issue tracker](https://github.com/overtrue/laravel-package/issues).\n3. Contribute new features or update the wiki.\n\n_The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any\nnew code contributions must be accompanied by unit tests where applicable._\n\n## PHP 扩展包开发\n\n\u003e 想知道如何从零开始构建 PHP 扩展包？\n\u003e\n\u003e 请关注我的实战课程，我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Flaravel-qcloud-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovertrue%2Flaravel-qcloud-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Flaravel-qcloud-captcha/lists"}