@@ -42,7 +42,7 @@ class ReCaptcha {
42
42
* @param string $secret
43
43
* @param string $lang
44
44
*/
45
- public function __construct ($ siteKey , $ secret , $ lang = ' en ' )
45
+ public function __construct ($ siteKey , $ secret , $ lang = null )
46
46
{
47
47
$ this ->siteKey = $ siteKey ;
48
48
$ this ->secret = $ secret ;
@@ -78,7 +78,7 @@ public function getLang()
78
78
{
79
79
return $ this ->lang ;
80
80
}
81
-
81
+
82
82
/**
83
83
* Set the language
84
84
*
@@ -91,7 +91,7 @@ public function setLang($lang)
91
91
92
92
/**
93
93
* Set the Request to use in the verifyRequest() call
94
- *
94
+ *
95
95
* @param Request $request
96
96
*/
97
97
public function setRequest (Request $ request )
@@ -123,17 +123,12 @@ public function getScriptSrc($render = null, $onload = null)
123
123
{
124
124
$ params = array (
125
125
'hl ' => $ this ->lang ,
126
+ 'render ' => $ render ,
127
+ 'onload ' => $ onload ,
126
128
);
127
129
128
- if ($ render ) {
129
- $ params ['render ' ] = $ render ;
130
- }
131
-
132
- if ($ onload ) {
133
- $ params ['onload ' ] = $ onload ;
134
- }
135
-
136
- return $ this ->scriptUrl . '? ' . http_build_query ($ params );
130
+ $ qs = http_build_query ($ params );
131
+ return $ this ->scriptUrl . ($ qs ? '? ' . $ qs : '' );
137
132
}
138
133
139
134
/**
@@ -160,12 +155,9 @@ public function verify($response, $remoteip = null)
160
155
$ params = array (
161
156
'secret ' => $ this ->secret ,
162
157
'response ' => $ response ,
158
+ 'remoteip ' => $ remoteip ,
163
159
);
164
160
165
- if ($ remoteip ) {
166
- $ params ['remoteip ' ] = $ remoteip ;
167
- }
168
-
169
161
$ response = $ this ->fetchResponse ($ params );
170
162
171
163
if ($ response ['success ' ]) {
0 commit comments