https://codeforgeek.com/2014/12/google- ... -tutorial/
先到 google recaptcha 申請:
https://www.google.com/recaptcha/
會取得 Site Key 與 Secret , 將取得的 Site Key 放到表單頁如下:
代碼: 選擇全部
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="[Site Key]"></div>
https://www.google.com/recaptcha/api/siteverify
內容包含:
secret / response (由表單頁帶來的 g-recaptcha-response) / remoteip
回應為 JSON
代碼: 選擇全部
{
"success": true|false,
"challenge_ts": timestamp, // timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ)
"hostname": string, // the hostname of the site where the reCAPTCHA was solved
"error-codes": [...] // optional
}