3
3
[ ![ Latest Version on Packagist] [ ico-version ]] [ link-packagist ]
4
4
[ ![ Total Downloads] [ ico-downloads ]] [ link-downloads ]
5
5
6
- STILL UNDER IMPLEMENTATION !!!
7
-
8
6
9
7
Google reCAPTCHA v3 is a new mechanism to verify whether the user is bot or not.
10
8
@@ -58,7 +56,7 @@ If your Laravel framework version is >= 5.5, just run the following command to p
58
56
$ php artisan vendor:publish --provider=" RyanDeng\GoogleReCaptcha\Providers\GoogleReCaptchaV3ServiceProvider"
59
57
```
60
58
61
- After installation, you should see a googlerecaptcha/ googlerecaptchav3.blade file in your views folder and googlerecaptchav3.php in your app/config folder.
59
+ After installation, you should see a googlerecaptchav3/field.blade and header .blade file in your views folder and googlerecaptchav3.php in your app/config folder.
62
60
63
61
## Basic Usage
64
62
#### Setting up your Google reCAPTCHA details in config file
@@ -69,7 +67,6 @@ Specify your Score threshold and action in 'setting', e.g.
69
67
``` php
70
68
'setting' = [
71
69
'action' => 'contact_us', // Google reCAPTCHA required paramater
72
- 'id' => 'contactus_id', // your HTML input field id
73
70
'threshold' => 0.2, // score threshold
74
71
'is_enabled' => false // if this is true, the system will do score comparsion against your threshold for the action
75
72
]
@@ -83,41 +80,34 @@ For more details please check comments in config file.
83
80
84
81
#### Display reCAPTCHA v3
85
82
83
+ Include Google API in header
84
+
86
85
``` html
87
- {!! app('captcha')->render($$action1,$action2... ) !!}
86
+ {!! GoogleReCaptchaV3::requireJs( ) !!}
88
87
```
89
88
90
- Or use Facade
89
+ Include input field
90
+
91
91
``` html
92
- {!! GoogleReCaptchaV3::render($action1,$action2 ) !!}
92
+ {!! GoogleReCaptchaV3::render('contact_us' ) !!}
93
93
```
94
94
95
95
Example Usage
96
96
97
97
``` html
98
- {!! GoogleReCaptchaV3::render($action1,$action2 ) !!}
98
+ {!! GoogleReCaptchaV3::requireJs( ) !!}
99
99
100
- <form method =" POST" action =" /verify1 " >
100
+ <form method =" POST" action =" /verify " >
101
101
@csrf
102
- <input type =" hidden" id =" your_id_1" name =" g-recaptcha-response" >
102
+ <input type =" hidden" id =" contactus_id" name =" g-recaptcha-response" >
103
+ {!! GoogleReCaptchaV3::render('contact_us') !!}
104
+
103
105
<input type =" submit" class =" g-recaptcha" value =" submit" >
104
106
</form >
105
107
106
- <form method =" POST" action =" /verify2" >
107
- @csrf
108
- <input type =" hidden" id =" your_id_2" name =" g-recaptcha-response" >
109
- <input type =" submit" class =" g-recaptcha" value =" submit" >
110
- </form >
111
108
```
112
109
113
- - You can pass multiple $action in render(...)function
114
- - Each action should have its own mapped id which you have specified in setting file.
115
- - Please specify your id for the input below:
116
-
117
- ``` html
118
- <input type =" hidden" id =" your_id" name =" g-recaptcha-response" >
119
- ```
120
- Note: all values should be registered in googlerecaptchav3 config file in 'setting' section.
110
+ Note: all actions should be registered in googlerecaptchav3 config file in 'setting' section.
121
111
122
112
123
113
#### Validation Class (Only support Laravel >= 5.5)
@@ -127,7 +117,7 @@ Note: all values should be registered in googlerecaptchav3 config file in 'setti
127
117
``` php
128
118
use RyanDeng\GoogleReCaptcha\Validations\GoogleReCaptchaValidationRule
129
119
$rule = [
130
- 'g-recaptcha-response' => [new GoogleReCaptchaValidationRule('action_name',$ip )]
120
+ 'g-recaptcha-response' => [new GoogleReCaptchaValidationRule('action_name')]
131
121
];
132
122
```
133
123
@@ -136,14 +126,11 @@ Note: all values should be registered in googlerecaptchav3 config file in 'setti
136
126
GoogleReCaptchaValidationRule($actionName, $ip) which accepts two optional parameters:
137
127
- $actionName: if its NULL, the package won't verify action with google response.
138
128
139
- - $ip: request remote ip, this is Google reCAPTCHA parameter.
140
-
141
-
142
129
#### Facade Class
143
130
144
131
145
132
``` php
146
- GoogleReCaptchaV3::setAction($action)->verifyResponse($response, $ip );
133
+ GoogleReCaptchaV3::setAction($action)->verifyResponse($response);
147
134
```
148
135
149
136
$action: Google reCAPTCHA definition
@@ -173,7 +160,7 @@ Remember to register your implementation, e.g.
173
160
174
161
#### Custom implementation on Request method
175
162
176
- The package uses Curl to verify, if you want to use your own request method, You can create your own class and implement
163
+ The package uses Guzzle\Http to verify, if you want to use your own request method, You can create your own class and implement
177
164
```
178
165
RyanDeng\GoogleReCaptcha\Interfaces\RequestClientInterface
179
166
```
@@ -186,9 +173,6 @@ Remember to register your implementation.
186
173
);
187
174
```
188
175
189
- ## Limitations
190
- One action can only map to one input field id, so you cannot declare multiple id to the same action.
191
-
192
176
## Security
193
177
194
178
If you discover any security related issues, please email ryandadeng@gmail.com instead of using the issue tracker.
0 commit comments