STEP I
查詢建立好的公私鑰: https://www.google.com/recaptcha/admin/site/350731086/settings
文章出處
這段代碼接到網站<head>裡面
網站架設然後在form的action程式裏面貼上利用這個function ,若是false就不給登入,就能夠啦~
網站架設
STEP III
- <div id="recaptcha_box2"></div>
複製代碼
STEP II


PHP驗證版
填入名稱、選擇驗證類型、網域、管理者,贊成Google蒐集網頁資訊、成立
- <!-- Google reCAPTCHA -->
- <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback2&render=explicit" async></script>
- <script>
- var onloadCallback2 = function() {
- grecaptcha.render("recaptcha_box2", {
- /* Change Your sitekey */
- "sitekey": "公鑰",
- "callback": callback2
- });
- };
-
- function callback2() {
- /* 這裡可履行提交表單的動作
- alert("恭喜你驗證成功");
- */
- document.getElementById("submit2").disabled = false;
- document.getElementById("submit2").classList.remove('au-btn--gray');
- document.getElementById("submit2").classList.add('au-btn--yellow');
- }
- </script>
複製代碼
前往 Google機械人官網,點選右上的 「Admin console」按鈕。
網站架設
- // GOOGLE RECAPTHA
- $data['secret'] = '私鑰';
- $data['response'] = $_POST['g-recaptcha-response'];
- $ch = curl_init();
- // 利用CURL驗證
- curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
- $result = curl_exec($ch);
- curl_close($ch);
- // 解密
- $result = json_decode($result, true);
-
- // 查抄是不是通過驗證
- if ( ! isset($result['success']) || ! $result['success']) {
- // 驗證失敗
- echo "<script>alert('驗證碼機械人失敗!');history.go(-1);</script>";
- exit;
- }
複製代碼 網站架設


如果已註冊過,想查詢自己的公私鑰:
https://www.google.com/recaptcha/admin#list
還沒註冊過的,下面三步驟建樹Google reCAPTCHA~
選1.勾選我不是機械人


下方則是貼到要顯示的位置
本篇文章引用自此:
文章定位: