Skip to content

Commit 64bafa7

Browse files
committed
Tweak params
Null values don't get included with http_build_query, leave default language null.
1 parent 761d5d1 commit 64bafa7

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/ReCaptcha.php

+8-16
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ReCaptcha {
4242
* @param string $secret
4343
* @param string $lang
4444
*/
45-
public function __construct($siteKey, $secret, $lang = 'en')
45+
public function __construct($siteKey, $secret, $lang = null)
4646
{
4747
$this->siteKey = $siteKey;
4848
$this->secret = $secret;
@@ -78,7 +78,7 @@ public function getLang()
7878
{
7979
return $this->lang;
8080
}
81-
81+
8282
/**
8383
* Set the language
8484
*
@@ -91,7 +91,7 @@ public function setLang($lang)
9191

9292
/**
9393
* Set the Request to use in the verifyRequest() call
94-
*
94+
*
9595
* @param Request $request
9696
*/
9797
public function setRequest(Request $request)
@@ -123,17 +123,12 @@ public function getScriptSrc($render = null, $onload = null)
123123
{
124124
$params = array(
125125
'hl' => $this->lang,
126+
'render' => $render,
127+
'onload' => $onload,
126128
);
127129

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 : '');
137132
}
138133

139134
/**
@@ -160,12 +155,9 @@ public function verify($response, $remoteip = null)
160155
$params = array(
161156
'secret' => $this->secret,
162157
'response' => $response,
158+
'remoteip' => $remoteip,
163159
);
164160

165-
if ($remoteip) {
166-
$params['remoteip'] = $remoteip;
167-
}
168-
169161
$response = $this->fetchResponse($params);
170162

171163
if ($response['success']) {

0 commit comments

Comments
 (0)