Verify A Recaptcha V3 Token. - Gists · GitHub
Maybe your like
Skip to content Search Gists Search Gists All gists Back to GitHub Sign in Sign up Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }}
NachoToast/captcha.php Created April 27, 2021 06:43 Show Gist options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment You can’t perform that action at this time.
Instantly share code, notes, and snippets.
- Download ZIP
- Star (2) You must be signed in to star a gist
- Fork (2) You must be signed in to fork a gist
- Embed Select an option
- Embed Embed this gist in your website.
- Share Copy sharable link for this gist.
- Clone via HTTPS Clone using the web URL.
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/NachoToast/f54bcf275a85b242a82d1a9f9e027321.js"></script> - Save NachoToast/f54bcf275a85b242a82d1a9f9e027321 to your computer and use it in GitHub Desktop.
- Embed Embed this gist in your website.
- Share Copy sharable link for this gist.
- Clone via HTTPS Clone using the web URL.
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/NachoToast/f54bcf275a85b242a82d1a9f9e027321.js"></script> Save NachoToast/f54bcf275a85b242a82d1a9f9e027321 to your computer and use it in GitHub Desktop. Download ZIP Verify a recaptcha v3 token. Raw captcha.php This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters| <?php |
| function verify_captcha($token) { |
| $threshold = 0.5; // Score must be > threshold to pass captcha. |
| // Default is 0.5, although the majority of users will get 0.9 |
| $sites = ["localhost", "nachotoast.com", "ntgc.ddns.net"]; // Site names string, e.g. sub.domain.com:8080 |
| $secret = "Put your client secret here."; |
| $url = "https://www.google.com/recaptcha/api/siteverify"; |
| $data = array("secret" => $secret, "response" => $token); |
| $options = array( |
| "http" => array( |
| "header" => "Content-type: application/x-www-form-urlencoded\r\n", |
| "method" => "POST", |
| "content" => http_build_query($data) |
| ) |
| ); |
| $context = stream_context_create($options); |
| $response = file_get_contents($url, false, $context); |
| $response_keys = json_decode($response, true); |
| // error checks |
| if (isset($response_keys["error-codes"])) { |
| if (in_array("timeout-or-duplicate", $response_keys["error-codes"])) return "expired"; |
| return $response_keys["error-codes"]; |
| } |
| // success check (theoretically not needed due to above error checks) |
| if ($response_keys["success"] !== true) return "invalid-token"; |
| // score check |
| if ($response_keys["score"] < $threshold) return "failed"; |
| // hostname check |
| if (!in_array($response_keys["hostname"], $sites)) return "wrong-site"; |
| // action check |
| if ($response_keys["action"] !== "submit") return "wrong-action"; |
| return true; |
| } |
Tag » How To Check Recaptcha V3 Score
-
Score Detector For ReCAPTCHA V3
-
Request Scores - ReCAPTCHA Demo
-
Google ReCAPTCHA V3 Score - YouTube
-
You Can View Your ReCaptcha V3 Score Here: Https://recaptcha-demo ...
-
Am I Supposed To Check User Score In ReCAPTCHA V3?
-
Google ReCAPTCHA V3 Score - Wicky Design
-
How To Use Google ReCAPTCHA V2 Or V3 On Your Tendenci Site
-
Google ReCAPTCHA V3 | Branch CMS Documentation
-
Recaptcha/recaptcha-v3-request-p At Master - GitHub
-
Check ReCAPTCHA 3 Score | AntiCaptcha Plugin Demo Forms
-
Concept - ReCaptcha V3