Guzzle 问题 missing-input-secret & missing-input-response
Guzzle issue missing-input-secret & missing-input-response
我正在使用 Guzzle 6.5.0 和 Laravel 6.7.0 当通过 Guzzle 验证 Google reCaptcha 时,似乎请求 Body / form_params
不包含在 POST 参数中。下面是 PHPUnit 8.5.0 的输出...
object(GuzzleHttp\Psr7\Request)#1179 (7) {
["method":"GuzzleHttp\Psr7\Request":private]=>
string(4) "POST"
["requestTarget":"GuzzleHttp\Psr7\Request":private]=>
NULL
["uri":"GuzzleHttp\Psr7\Request":private]=>
object(GuzzleHttp\Psr7\Uri)#1180 (7) {
["scheme":"GuzzleHttp\Psr7\Uri":private]=>
string(5) "https"
["userInfo":"GuzzleHttp\Psr7\Uri":private]=>
string(0) ""
["host":"GuzzleHttp\Psr7\Uri":private]=>
string(14) "www.google.com"
["port":"GuzzleHttp\Psr7\Uri":private]=>
NULL
["path":"GuzzleHttp\Psr7\Uri":private]=>
string(25) "/recaptcha/api/siteverify"
["query":"GuzzleHttp\Psr7\Uri":private]=>
string(0) ""
["fragment":"GuzzleHttp\Psr7\Uri":private]=>
string(0) ""
}
["headers":"GuzzleHttp\Psr7\Request":private]=>
array(3) {
["Host"]=>
array(1) {
[0]=>
string(14) "www.google.com"
}
["headers"]=>
array(1) {
["Content-Type"]=>
string(33) "application/x-www-form-urlencoded"
}
["form_params"]=>
array(2) {
["secret"]=>
string(40) "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
["response"]=>
string(3) "123"
}
}
["headerNames":"GuzzleHttp\Psr7\Request":private]=>
array(3) {
["headers"]=>
string(7) "headers"
["form_params"]=>
string(11) "form_params"
["host"]=>
string(4) "Host"
}
["protocol":"GuzzleHttp\Psr7\Request":private]=>
string(3) "1.1"
["stream":"GuzzleHttp\Psr7\Request":private]=>
object(GuzzleHttp\Psr7\Stream)#1182 (7) {
["stream":"GuzzleHttp\Psr7\Stream":private]=>
resource(609) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=>
int(0)
["seekable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["readable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["writable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["uri":"GuzzleHttp\Psr7\Stream":private]=>
string(10) "php://temp"
["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
array(0) {
}
}
Content-Type
header 是手动设置的。在 Laravel 中,我可以访问秘密和 URL,所以这不是问题所在。特别是因为请求被发送到正确的 URL。任何帮助将不胜感激。
这里解释了问题/为什么它不起作用:
我混淆了客户端和请求选项:
https://github.com/guzzle/psr7/issues/179
希望这对其他人有所帮助!
我正在使用 Guzzle 6.5.0 和 Laravel 6.7.0 当通过 Guzzle 验证 Google reCaptcha 时,似乎请求 Body / form_params
不包含在 POST 参数中。下面是 PHPUnit 8.5.0 的输出...
object(GuzzleHttp\Psr7\Request)#1179 (7) {
["method":"GuzzleHttp\Psr7\Request":private]=>
string(4) "POST"
["requestTarget":"GuzzleHttp\Psr7\Request":private]=>
NULL
["uri":"GuzzleHttp\Psr7\Request":private]=>
object(GuzzleHttp\Psr7\Uri)#1180 (7) {
["scheme":"GuzzleHttp\Psr7\Uri":private]=>
string(5) "https"
["userInfo":"GuzzleHttp\Psr7\Uri":private]=>
string(0) ""
["host":"GuzzleHttp\Psr7\Uri":private]=>
string(14) "www.google.com"
["port":"GuzzleHttp\Psr7\Uri":private]=>
NULL
["path":"GuzzleHttp\Psr7\Uri":private]=>
string(25) "/recaptcha/api/siteverify"
["query":"GuzzleHttp\Psr7\Uri":private]=>
string(0) ""
["fragment":"GuzzleHttp\Psr7\Uri":private]=>
string(0) ""
}
["headers":"GuzzleHttp\Psr7\Request":private]=>
array(3) {
["Host"]=>
array(1) {
[0]=>
string(14) "www.google.com"
}
["headers"]=>
array(1) {
["Content-Type"]=>
string(33) "application/x-www-form-urlencoded"
}
["form_params"]=>
array(2) {
["secret"]=>
string(40) "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
["response"]=>
string(3) "123"
}
}
["headerNames":"GuzzleHttp\Psr7\Request":private]=>
array(3) {
["headers"]=>
string(7) "headers"
["form_params"]=>
string(11) "form_params"
["host"]=>
string(4) "Host"
}
["protocol":"GuzzleHttp\Psr7\Request":private]=>
string(3) "1.1"
["stream":"GuzzleHttp\Psr7\Request":private]=>
object(GuzzleHttp\Psr7\Stream)#1182 (7) {
["stream":"GuzzleHttp\Psr7\Stream":private]=>
resource(609) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=>
int(0)
["seekable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["readable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["writable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["uri":"GuzzleHttp\Psr7\Stream":private]=>
string(10) "php://temp"
["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
array(0) {
}
}
Content-Type
header 是手动设置的。在 Laravel 中,我可以访问秘密和 URL,所以这不是问题所在。特别是因为请求被发送到正确的 URL。任何帮助将不胜感激。
这里解释了问题/为什么它不起作用:
我混淆了客户端和请求选项:
https://github.com/guzzle/psr7/issues/179
希望这对其他人有所帮助!