[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-8490":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":17,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":15,"lastSyncTime":29,"discoverSource":30},8490,"recaptcha","google\u002Frecaptcha","google","PHP client library for reCAPTCHA, a free service to protect your website from spam and abuse.","http:\u002F\u002Fwww.google.com\u002Frecaptcha\u002F",null,"PHP",3565,778,120,2,0,1,4,30.67,"BSD 3-Clause \"New\" or \"Revised\" License",false,"main",[24,5,25],"abuse","spam","2026-06-12 02:01:54","# reCAPTCHA PHP client library\n\n\n[![Latest stable version](https:\u002F\u002Fposer.pugx.org\u002Fgoogle\u002Frecaptcha\u002Fv\u002Fstable.svg)](https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fgoogle\u002Frecaptcha)\n[![PHP version required](https:\u002F\u002Fposer.pugx.org\u002Fgoogle\u002Frecaptcha\u002Frequire\u002Fphp)](https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fgoogle\u002Frecaptcha)\n[![Coverage Status](https:\u002F\u002Fcoveralls.io\u002Frepos\u002Fgithub\u002Fgoogle\u002Frecaptcha\u002Fbadge.svg?branch=main)](https:\u002F\u002Fcoveralls.io\u002Fgithub\u002Fgoogle\u002Frecaptcha?branch=main)\n[![Total downloads](https:\u002F\u002Fposer.pugx.org\u002Fgoogle\u002Frecaptcha\u002Fdownloads.svg)](https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fgoogle\u002Frecaptcha)\n[![License](https:\u002F\u002Fposer.pugx.org\u002Fgoogle\u002Frecaptcha\u002Flicense.svg)](https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fgoogle\u002Frecaptcha)\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:\u002F\u002Fcloud.google.com\u002Fsecurity\u002Fproducts\u002Frecaptcha\n- This repo: https:\u002F\u002Fgithub.com\u002Fgoogle\u002Frecaptcha\n- Hosted demo: https:\u002F\u002Frecaptcha-demo.appspot.com\u002F\n- Version: 1.5.0\n- License: BSD, see [LICENSE](LICENSE)\n\n> [!IMPORTANT]\n> **reCAPTCHA Enterprise** is supported via the [Google Cloud Recaptcha Enterprise for\nPHP client](https:\u002F\u002Fdocs.cloud.google.com\u002Fphp\u002Fdocs\u002Freference\u002Fcloud-recaptcha-enterprise\u002F).\n\n## Installation\n\n### Composer (recommended)\n\nUse [Composer](https:\u002F\u002Fgetcomposer.org) to install this library from Packagist:\n[`google\u002Frecaptcha`](https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fgoogle\u002Frecaptcha)\n\nRun the following command from your project directory to add the dependency:\n\n```sh\ncomposer require google\u002Frecaptcha \"^1.5\"\n```\n\nAlternatively, add the dependency directly to your `composer.json` file:\n\n```json\n\"require\": {\n    \"google\u002Frecaptcha\": \"^1.5\"\n}\n```\n\n### Support for earlier versions of PHP\n\nFrom the 1.3 release support moved to PHP 8 and up. For earlier versions, you\nwill need to stay with the 1.2 releases.\n\n### Direct download\n\nDownload the [ZIP file](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Frecaptcha\u002Farchive\u002Fmain.zip)\nand extract into your project. An autoloader script is provided in\n`src\u002Fautoload.php` which you can require into your script. For example:\n\n```php\nrequire_once '\u002Fpath\u002Fto\u002Frecaptcha\u002Fsrc\u002Fautoload.php';\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret);\n```\n\nThe classes in the project are structured according to the\n[PSR-4](https:\u002F\u002Fwww.php-fig.org\u002Fpsr\u002Fpsr-4\u002F) 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 at https:\u002F\u002Fwww.google.com\u002Frecaptcha\u002Fadmin.\n\nThen follow the [integration guide on the developer\nsite](https:\u002F\u002Fdevelopers.google.com\u002Frecaptcha\u002Fintro) 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[\\ReCaptcha\\ReCaptcha::USER_TOKEN_PARAMETER]` or the\nresponse from `grecaptcha.execute()` in JS which is in `$gRecaptchaResponse` in\nthe example) and user's IP address. For example:\n\n```php\n\u003C?php\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret);\n$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')\n                  ->verify($gRecaptchaResponse, $remoteIp);\nif ($resp->isSuccess()) {\n    \u002F\u002F Verified!\n} else {\n    $errors = $resp->getErrorCodes();\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\u002FPackage Name Validation\" for your\n  credentials. **Note:** if you need to validate against multiple hostnames,\n  do not use this method. Instead, check the `$resp->getHostname()` against\n  your list of allowed hostnames after calling `verify()`.\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\u002FPackage 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->setExpectedHostname('recaptcha-demo.appspot.com')\n                  ->setExpectedAction('homepage')\n                  ->setScoreThreshold(0.5)\n                  ->verify($gRecaptchaResponse, $remoteIp);\n\nif ($resp->isSuccess()) {\n    \u002F\u002F Verified!\n} else {\n    $errors = $resp->getErrorCodes();\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\n### Alternate request methods\n\n> [!NOTE]\n> As of version 1.4.2, the default behavior has changed.\n\nBy default, the library will attempt to use [cURL](https:\u002F\u002Fsecure.php.net\u002Fcurl) to make the\nPOST request to the reCAPTCHA service. This is handled by the\n[`RequestMethod\\CurlPost`](.\u002Fsrc\u002FReCaptcha\u002FRequestMethod\u002FCurlPost.php) class.\nIf cURL is not available, it will fall back to using\n[`stream_context_create()`](https:\u002F\u002Fsecure.php.net\u002Fstream_context_create) and\n[`file_get_contents()`](https:\u002F\u002Fsecure.php.net\u002Ffile_get_contents) via the\n[`RequestMethod\\Post`](.\u002Fsrc\u002FReCaptcha\u002FRequestMethod\u002FPost.php) class.\n\nTo keep the previous behavior of always using `file_get_contents()` regardless of cURL's availability, you can explicitly configure it:\n\n```php\n\u003C?php\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret, new \\ReCaptcha\\RequestMethod\\Post());\n```\n\nYou may need to use other methods for making requests in your environment. The\n[`ReCaptcha`](.\u002Fsrc\u002FReCaptcha\u002FReCaptcha.php) class allows an optional\n[`RequestMethod`](.\u002Fsrc\u002FReCaptcha\u002FRequestMethod.php) instance to configure this.\nFor example, if you want to force the use of [cURL](https:\u002F\u002Fsecure.php.net\u002Fcurl) you\ncan do this:\n\n```php\n\u003C?php\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret, new \\ReCaptcha\\RequestMethod\\CurlPost());\n```\n\nAlternatively, you can also use a [socket](https:\u002F\u002Fsecure.php.net\u002Ffsockopen):\n\n```php\n\u003C?php\n$recaptcha = new \\ReCaptcha\\ReCaptcha($secret, new \\ReCaptcha\\RequestMethod\\SocketPost());\n```\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\u002F](examples\u002F). 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:\u002F\u002Flocalhost:8080\u002F\n\nThese are also hosted on Google AppEngine Flexible environment at\nhttps:\u002F\u002Frecaptcha-demo.appspot.com\u002F. This is configured by\n[`app.yaml`](.\u002Fapp.yaml) which you can also use to [deploy to your own AppEngine\nproject](https:\u002F\u002Fcloud.google.com\u002Fappengine\u002Fdocs\u002Fflexible\u002Fphp\u002Fdownload).\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\nTo set up your local checkout, install the dependencies:\n\n```bash\ncomposer install\n```\n\nIf you add new dependencies to the project, make sure you commit the lock file:\n\n```bash\ncomposer update\ngit add composer.json composer.lock\n```\n\nBefore committing code, make sure it meets the quality and formatting standards:\n\n```bash\ncomposer run phpstan\ncomposer run lint-fix\n```\n\nRun the tests before submitting. Make sure you add or update tests to cover any changes you make:\n\n```bash\ncomposer run test\n```\n","reCAPTCHA 是一个免费的 CAPTCHA 服务，旨在保护网站免受垃圾邮件和滥用。该项目提供了一个 PHP 客户端库，用于封装 reCAPTCHA 服务所需的服务器端验证步骤，支持 reCAPTCHA v2 和 v3 版本。其主要功能包括通过简单的 API 调用实现用户响应验证，以及易于集成到现有 PHP 应用中的特性。适用于需要增强安全性的各类网站场景，如登录、注册页面或任何形式的在线表单提交过程，帮助开发者有效防止自动化攻击和恶意行为。","2026-06-11 03:18:17","top_language"]