vendor/wechatpay/wechatpay/src/Transformer.php 154 行
类型错误: WeChatPay\Transformer::content(): Argumen #2 ($thing) must be of type string, int given, called in
这里是类型报错,我也不知怎么回事, 链接个字符串转换一下就好了
vendor\wechatpay\wechatpay\src\Transformer.php on line 154
这个错误修改好之后
The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information.
经过漫长的排队等待, 等到在线客服, 客服说让我用postman试一下,
于是, 在服务器上搞了个postman, 结果执行成功了, 返回的信息告诉我金额太小了,最低不能小于1块钱, 我把金额调大就成功了, 但是没有接收到返回信息, 还是那个错误,但是接口却调用成功了, 因为我都收到钱了
后来根据大佬的提示修改了配置信息, 关闭Guzzle重试, 试了一下,好像没起作用,还是报了相同的错误
再后来,我又根据大佬的提示增加了一个handler
[],
'security' => true,
'verify' => false,
'retries' => 0,//关闭Guzzle重试
'handler' => function ($p1,$p2,$p3=false)
{
var_dump('p1:');
var_dump($p1);
var_dump('p2:');
var_dump($p2);
var_dump('p3:');
var_dump($p3);
// return $ret;
},
增加了这个之后呢, 就不走异常了, 就直接走到then里面了, 但是then里面的response是NULL, 让人很郁闷,
于是, 我又把handler给注释掉了, 我想再请求一次看看效果, 然后,神奇的事情发生了, 这次竟然不报那个错误了, 而是换了另一个错误
Cannot represent a stream of type Output as a STDIO FILE
我也不知道为啥会是这样, 这次我也收不到钱了,证明接口根本就每调用成功,
然后, 有找到资料说要加上这一行
unset($conf[CURLOPT_STDERR]); //添加此行
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php 70行
然后, 返回虽然还是在otherwise里面,但是返回正常了,如下
dddobject(GuzzleHttp\Psr7\Response)#118 (6) {
["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>
string(2) "OK"
["statusCode":"GuzzleHttp\Psr7\Response":private]=>
int(200)
["headers":"GuzzleHttp\Psr7\Response":private]=>
array(7) {
["Server"]=>
array(1) {
[0]=>
string(5) "nginx"
}
["Date"]=>
array(1) {
[0]=>
string(29) "Mon, 20 Dec 2021 12:51:37 GMT"
}
["Content-Type"]=>
array(1) {
[0]=>
string(23) "text/xml; charset=UTF-8"
}
["Content-Length"]=>
array(1) {
[0]=>
string(3) "517"
}
["Connection"]=>
array(1) {
[0]=>
string(10) "keep-alive"
}
["Keep-Alive"]=>
array(1) {
[0]=>
string(9) "timeout=8"
}
["Cache-Control"]=>
array(1) {
[0]=>
string(25) "no-cache, must-revalidate"
}
}
["headerNames":"GuzzleHttp\Psr7\Response":private]=>
array(7) {
["server"]=>
string(6) "Server"
["date"]=>
string(4) "Date"
["content-type"]=>
string(12) "Content-Type"
["content-length"]=>
string(14) "Content-Length"
["connection"]=>
string(10) "Connection"
["keep-alive"]=>
string(10) "Keep-Alive"
["cache-control"]=>
string(13) "Cache-Control"
}
["protocol":"GuzzleHttp\Psr7\Response":private]=>
string(3) "1.1"
["stream":"GuzzleHttp\Psr7\Response":private]=>
object(GuzzleHttp\Psr7\Stream)#101 (7) {
["stream":"GuzzleHttp\Psr7\Stream":private]=>
resource(16) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=>
NULL
["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) {
}
}
}
reArray
(
)
至少里面有个ok了不是,
然后打印了一下 $e 得类型
otherwise(static function($e) {
echo 'ddd';
// error_reporting(3);
var_dump($e);
var_dump(get_class($e));
string(24) "GuzzleHttp\Psr7\Response"
就这么好了?(稀里糊涂的就好了?)
otherwise(static function($e) {
echo 'ddd';
// error_reporting(3);
var_dump($e);
var_dump(get_class($e));
if($e instanceof Response){
var_dump($e->getBody());
}
然后出来的是这个东西
object(GuzzleHttp\Psr7\Stream)#101 (7) {
["stream":"GuzzleHttp\Psr7\Stream":private]=>
resource(16) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=>
NULL
["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) {
}
}
貌似得转换一下:
var_dump( Transformer::toArray((string)$e->getBody()));
array(7) {
["return_code"]=>
string(7) "SUCCESS"
["return_msg"]=>
string(12) "支付失败"
["mch_appid"]=>
string(18) "w88888888888888"
["mchid"]=>
string(10) "8888888"
["result_code"]=>
string(4) "FAIL"
["err_code"]=>
string(12) "AMOUNT_LIMIT"
["err_code_des"]=>
string(81) "付款金额超出限制。低于最小金额1.00元或累计超过20000.00元。"
}
???
这就可以了?
我把调试模式关闭了试一下
没问题还是原来的返回, 然后根据这个数组来处理业务就行了...,为什么就好了呢???
ext-curl 这个插件怎么装,没找到 windows服务器 PHP8
See https://bugs.php.net/bug.php?id=47204 最末尾5行记录如下,最后一条跟你遇到的情况基本一致,解决方案是:"to fix this, redo the plugin(ext-curl) setup"
[2009-11-14 15:39 UTC] avb@php.net
While adding PHP-side support for CURLOPT_IOCTLFUNCTION is indeed a feature request, complete inability for curl extension to handle redirects / digest authentication when using CURLOPT_INFILE (CURLOPT_READDATA) looks like a genuine bug to me. The problem lies with Curl extension registering a custom callback curl_read() as CURLOPT_READFUNCTION (it handles both reading from a stream provided as CURLOPT_INFILE and calling PHP callback provided as CURLOPT_READFUNCTION) but failing to implement custom callback for rewinding the data, at least for the case when stream is used.
[2009-11-14 16:02 UTC] avb@php.net
...also note that while this problem can be worked around by using CURLOPT_POSTFIELDS with POST request, other request methods (e.g. PUT) only allow using CURLOPT_INFILE as request body.
[2009-11-15 10:53 UTC] svn@php.net
Automatic comment from SVN on behalf of avb Revision: http://svn.php.net/viewvc/?view=revision&revision=290773 Log: Added workaround for PHP bug #47204 Added handling for 'strict_redirects' in Curl Adapter when CURLOPT_POSTREDIR is available
[2010-12-09 04:47 UTC] srinatar@php.net
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To: srinatar
+Assigned To:
[2021-09-11 12:02 UTC] theasialive at gmail dot com
Unknown Error (code: The cURL request was retried 3 times and did no succeed. cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information.). To fix this, redo the plugin setup.