Guzzle 问题缺少输入秘密和缺少输入响应



我正在使用Guzzle 6.5.0和Laravel 6.7.0 当通过Guzzle验证Google reCaptcha时,似乎请求正文/form_params不包含在POST参数中。下面是 PHPUnit 8.5.0 输出...

object(GuzzleHttpPsr7Request)#1179 (7) {
["method":"GuzzleHttpPsr7Request":private]=>
string(4) "POST"
["requestTarget":"GuzzleHttpPsr7Request":private]=>
NULL
["uri":"GuzzleHttpPsr7Request":private]=>
object(GuzzleHttpPsr7Uri)#1180 (7) {
["scheme":"GuzzleHttpPsr7Uri":private]=>
string(5) "https"
["userInfo":"GuzzleHttpPsr7Uri":private]=>
string(0) ""
["host":"GuzzleHttpPsr7Uri":private]=>
string(14) "www.google.com"
["port":"GuzzleHttpPsr7Uri":private]=>
NULL
["path":"GuzzleHttpPsr7Uri":private]=>
string(25) "/recaptcha/api/siteverify"
["query":"GuzzleHttpPsr7Uri":private]=>
string(0) ""
["fragment":"GuzzleHttpPsr7Uri":private]=>
string(0) ""
}
["headers":"GuzzleHttpPsr7Request":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":"GuzzleHttpPsr7Request":private]=>
array(3) {
["headers"]=>
string(7) "headers"
["form_params"]=>
string(11) "form_params"
["host"]=>
string(4) "Host"
}
["protocol":"GuzzleHttpPsr7Request":private]=>
string(3) "1.1"
["stream":"GuzzleHttpPsr7Request":private]=>
object(GuzzleHttpPsr7Stream)#1182 (7) {
["stream":"GuzzleHttpPsr7Stream":private]=>
resource(609) of type (stream)
["size":"GuzzleHttpPsr7Stream":private]=>
int(0)
["seekable":"GuzzleHttpPsr7Stream":private]=>
bool(true)
["readable":"GuzzleHttpPsr7Stream":private]=>
bool(true)
["writable":"GuzzleHttpPsr7Stream":private]=>
bool(true)
["uri":"GuzzleHttpPsr7Stream":private]=>
string(10) "php://temp"
["customMetadata":"GuzzleHttpPsr7Stream":private]=>
array(0) {
}
}

Content-Type标头是手动设置的。在 Laravel,我可以访问密钥和 URL,所以这不是问题。特别是因为请求被发送到正确的 URL。任何帮助将不胜感激。

这里解释了问题/为什么它不起作用:

我混淆了客户端与请求选项:

https://github.com/guzzle/psr7/issues/179

希望这对其他人有所帮助!

最新更新