forked from sperti/recaptchav2phplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
53 lines (32 loc) · 1.28 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
reCAPTCHA v2 php plugin README
================
The reCAPTCHA v2 PHP Library helps you use the reCAPTCHA API. The library uses similar interface
to reCAPTCHA v1, so it is easier to switch to v2.
Documentation about reCAPTCHA v2 -> https://developers.google.com/recaptcha/intro
From reCATPCHA there are some changes like:
- RECAPTCHA_VERIFY_SERVER, now in https -> https://www.google.com/recaptcha/api/siteverify
- parameters to send by POST:
. secret
. remoteip
. response
To use this plugin, you can see the example-captcha file.
You have to:
- Create your public and private api key and include your domain(s)
https://www.google.com/recaptcha/admin
- Include the recaptchalib.php:
require_once('recaptchalib.php');
- add client side integration:
echo recaptcha_get_html($publickey);
- add the server side check, for example:
if ($_POST["g-recaptcha-response"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]);
if ($resp->is_valid) {
echo "Everything's OK!";
} else {
# set the error code so that we can display it
# use $resp->error for error message
$error = $resp->error_code;
}
}