{"id":13528140,"url":"https://github.com/google/recaptcha","last_synced_at":"2025-05-11T05:47:29.324Z","repository":{"id":21333457,"uuid":"24650294","full_name":"google/recaptcha","owner":"google","description":"PHP client library for reCAPTCHA, a free service to protect your website from spam and abuse.","archived":false,"fork":false,"pushed_at":"2024-07-29T13:55:05.000Z","size":294,"stargazers_count":3513,"open_issues_count":121,"forks_count":779,"subscribers_count":126,"default_branch":"master","last_synced_at":"2025-05-11T05:47:24.110Z","etag":null,"topics":["abuse","recaptcha","spam"],"latest_commit_sha":null,"homepage":"http://www.google.com/recaptcha/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"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}},"created_at":"2014-09-30T18:30:39.000Z","updated_at":"2025-05-11T04:07:41.000Z","dependencies_parsed_at":"2023-02-15T06:16:12.215Z","dependency_job_id":"bc293ff5-5645-413a-9049-bd58411eb49c","html_url":"https://github.com/google/recaptcha","commit_stats":{"total_commits":183,"total_committers":32,"mean_commits":5.71875,"dds":0.3005464480874317,"last_synced_commit":"6ffa193021aa0e369a3c5b3909de2b4ed97ac359"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frecaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frecaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frecaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frecaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/recaptcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523731,"owners_count":21921818,"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":["abuse","recaptcha","spam"],"created_at":"2024-08-01T06:02:14.410Z","updated_at":"2025-05-11T05:47:29.305Z","avatar_url":"https://github.com/google.png","language":"PHP","readme":"# reCAPTCHA PHP client library\n\n[![Build Status](https://travis-ci.org/google/recaptcha.svg)](https://travis-ci.org/google/recaptcha)\n[![Coverage Status](https://coveralls.io/repos/github/google/recaptcha/badge.svg)](https://coveralls.io/github/google/recaptcha)\n[![Latest Stable Version](https://poser.pugx.org/google/recaptcha/v/stable.svg)](https://packagist.org/packages/google/recaptcha)\n[![Total Downloads](https://poser.pugx.org/google/recaptcha/downloads.svg)](https://packagist.org/packages/google/recaptcha)\n\nreCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse.\nThis is a PHP library that wraps up the server-side verification step required\nto process responses from the reCAPTCHA service. This client supports both v2\nand v3.\n\n- reCAPTCHA: https://www.google.com/recaptcha\n- This repo: https://github.com/google/recaptcha\n- Hosted demo: https://recaptcha-demo.appspot.com/\n- Version: 1.3.0\n- License: BSD, see [LICENSE](LICENSE)\n\n## Installation\n\n### Composer (recommended)\n\nUse [Composer](https://getcomposer.org) to install this library from Packagist:\n[`google/recaptcha`](https://packagist.org/packages/google/recaptcha)\n\nRun the following command from your project directory to add the dependency:\n\n```sh\ncomposer require google/recaptcha \"^1.3\"\n```\n\nAlternatively, add the dependency directly to your `composer.json` file:\n\n```json\n\"require\": {\n    \"google/recaptcha\": \"^1.3\"\n}\n```\n\n### Support for earlier versions of PHP\n\nThe 1.3 release moves to PHP 8 and up. For earlier versions, you will need to\nstay with the 1.2 releases.\n\n### Direct download\n\nDownload the [ZIP file](https://github.com/google/recaptcha/archive/master.zip)\nand extract into your project. An autoloader script is provided in\n`src/autoload.php` which you can require into your script. For example:\n\n```php\nrequire_once '/path/to/recaptcha/src/autoload.php';\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret);\n```\n\nThe classes in the project are structured according to the\n[PSR-4](https://www.php-fig.org/psr/psr-4/) standard, so you can also use your\nown autoloader or require the needed files directly in your code.\n\n## Usage\n\nFirst obtain the appropriate keys for the type of reCAPTCHA you wish to\nintegrate for v2 at https://www.google.com/recaptcha/admin or v3 at\nhttps://g.co/recaptcha/v3.\n\nThen follow the [integration guide on the developer\nsite](https://developers.google.com/recaptcha/intro) to add the reCAPTCHA\nfunctionality into your frontend.\n\nThis library comes in when you need to verify the user's response. On the PHP\nside you need the response from the reCAPTCHA service and secret key from your\ncredentials. Instantiate the `ReCaptcha` class with your secret key, specify any\nadditional validation rules, and then call `verify()` with the reCAPTCHA\nresponse (usually in `$_POST['g-recaptcha-response']` or the response from\n`grecaptcha.execute()` in JS which is in `$gRecaptchaResponse` in the example)\nand user's IP address. For example:\n\n```php\n\u003c?php\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret);\n$resp = $recaptcha-\u003esetExpectedHostname('recaptcha-demo.appspot.com')\n                  -\u003everify($gRecaptchaResponse, $remoteIp);\nif ($resp-\u003eisSuccess()) {\n    // Verified!\n} else {\n    $errors = $resp-\u003egetErrorCodes();\n}\n```\n\nThe following methods are available:\n\n- `setExpectedHostname($hostname)`: ensures the hostname matches. You must do\n  this if you have disabled \"Domain/Package Name Validation\" for your\n  credentials.\n- `setExpectedApkPackageName($apkPackageName)`: if you're verifying a response\n  from an Android app. Again, you must do this if you have disabled\n  \"Domain/Package Name Validation\" for your credentials.\n- `setExpectedAction($action)`: ensures the action matches for the v3 API.\n- `setScoreThreshold($threshold)`: set a score threshold for responses from the\n  v3 API\n- `setChallengeTimeout($timeoutSeconds)`: set a timeout between the user passing\n  the reCAPTCHA and your server processing it.\n\nEach of the `set`\\*`()` methods return the `ReCaptcha` instance so you can chain\nthem together. For example:\n\n```php\n\u003c?php\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret);\n$resp = $recaptcha-\u003esetExpectedHostname('recaptcha-demo.appspot.com')\n                  -\u003esetExpectedAction('homepage')\n                  -\u003esetScoreThreshold(0.5)\n                  -\u003everify($gRecaptchaResponse, $remoteIp);\n\nif ($resp-\u003eisSuccess()) {\n    // Verified!\n} else {\n    $errors = $resp-\u003egetErrorCodes();\n}\n```\n\nYou can find the constants for the libraries error codes in the `ReCaptcha`\nclass constants, e.g. `ReCaptcha::E_HOSTNAME_MISMATCH`\n\nFor more details on usage and structure, see [ARCHITECTURE](ARCHITECTURE.md).\n\n### Examples\n\nYou can see examples of each reCAPTCHA type in [examples/](examples/). You can\nrun the examples locally by using the Composer script:\n\n```sh\ncomposer run-script serve-examples\n```\n\nThis makes use of the in-built PHP dev server to host the examples at\nhttp://localhost:8080/\n\nThese are also hosted on Google AppEngine Flexible environment at\nhttps://recaptcha-demo.appspot.com/. This is configured by\n[`app.yaml`](./app.yaml) which you can also use to [deploy to your own AppEngine\nproject](https://cloud.google.com/appengine/docs/flexible/php/download).\n\n## Contributing\n\nNo one ever has enough engineers, so we're very happy to accept contributions\nvia Pull Requests. For details, see [CONTRIBUTING](CONTRIBUTING.md)\n","funding_links":[],"categories":["PHP","Biblioteki","目录","常用验证码库","图像( Imagery )","类库"],"sub_categories":["图像 Imagery","未归类"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Frecaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Frecaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Frecaptcha/lists"}