|
58 | 58 | <meta property="og:description" content="reCAPTCHA demo - Request scores" />
|
59 | 59 | <link rel="stylesheet" type="text/css" href="/examples.css">
|
60 | 60 | <title>reCAPTCHA demo - Request scores</title>
|
61 |
| - |
62 | 61 | <header>
|
63 | 62 | <h1>reCAPTCHA demo</h1><h2>Request scores</h2>
|
64 | 63 | <p><a href="/">↤ Home</a></p>
|
|
73 | 72 | else:
|
74 | 73 | // Add the g-recaptcha tag to the form you want to include the reCAPTCHA element
|
75 | 74 | ?>
|
76 |
| - <p>reCAPTCHA will provide a score for this request.</p> |
| 75 | + <p>The reCAPTCHA v3 API provides a confidence score for each request.</p> |
| 76 | + <p><strong>NOTE:</strong>This is a sample implementation, the score returned here is not a reflection on your Google account or type of traffic. In production, refer to the distribution of scores shown in <a href="https://www.google.com/recaptcha/admin" target="_blank">your admin interface</a> and adjust your own threshold accordingly. <strong>Do not raise issues regarding the score you see here.</strong></p> |
77 | 77 | <ol id="recaptcha-steps">
|
78 | 78 | <li class="step0">reCAPTCHA script loading</li>
|
79 |
| - <li style="display:none" class="step1"><kbd>grecaptcha.ready()</kbd> fired, calling <pre>grecaptcha.execute('<?php echo $siteKey; ?>', {action: 'homepage'})'</pre></li> |
80 |
| - <li style="display:none" class="step2">Received token from reCAPTCHA service, sending to our backend with <kbd>fetch('/recaptcha-v3-verify.php?token='+<span class="token">123</span>)</kbd></li> |
81 |
| - <li style="display:none" class="step3">Received response from our backend: <pre class="response">response</pre></li> |
| 79 | + <li class="step1 hidden"><kbd>grecaptcha.ready()</kbd> fired, calling <pre>grecaptcha.execute('<?php echo $siteKey; ?>', {action: 'examples/v3scores'})'</pre></li> |
| 80 | + <li class="step2 hidden">Received token from reCAPTCHA service, sending to our backend with: |
| 81 | + <pre class="token">fetch('/recaptcha-v3-verify.php?token=abc123</pre></li> |
| 82 | + <li class="step3 hidden">Received response from our backend: <pre class="response">{"json": "from-backend"}</pre></li> |
82 | 83 | </ol>
|
83 | 84 | <p><a href="/recaptcha-v3-request-scores.php">⟳ Try again</a></p>
|
84 | 85 |
|
85 | 86 | <script src="https://www.google.com/recaptcha/api.js?render=<?php echo $siteKey; ?>"></script>
|
86 | 87 | <script>
|
87 | 88 | const steps = document.getElementById('recaptcha-steps');
|
88 | 89 | grecaptcha.ready(function() {
|
89 |
| - document.querySelector('.step1').style.display = 'list-item'; |
90 |
| - grecaptcha.execute('<?php echo $siteKey; ?>', {action: 'homepage'}).then(function(token) { |
91 |
| - document.querySelector('.token').innerHTML = token; |
92 |
| - document.querySelector('.step2').style.display = 'list-item'; |
| 90 | + document.querySelector('.step1').classList.remove('hidden'); |
| 91 | + grecaptcha.execute('<?php echo $siteKey; ?>', {action: 'examples/v3scores'}).then(function(token) { |
| 92 | + document.querySelector('.token').innerHTML = 'fetch(\'/recaptcha-v3-verify.php?token=\'' + token; |
| 93 | + document.querySelector('.step2').classList.remove('hidden'); |
93 | 94 |
|
94 | 95 | fetch('/recaptcha-v3-verify.php?token='+token).then(function(response) {
|
95 | 96 | response.json().then(function(data) {
|
96 | 97 | document.querySelector('.response').innerHTML = JSON.stringify(data, null, 2);
|
97 |
| - document.querySelector('.step3').style.display = 'list-item'; |
| 98 | + document.querySelector('.step3').classList.remove('hidden'); |
98 | 99 | });
|
99 | 100 | });
|
100 | 101 | });
|
|
0 commit comments