webman 使用 EasyWeChat 小程序配置报错

liupeng123456

bug描述

ErrorException: http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated in /www/wwwroot/diaoyutong.cn/vendor/guzzlehttp/guzzle/src/Client.php:445
Stack trace

程序代码或配置


这里粘代码或配置
$config = [
    'app_id' => ''******',',
    'secret' => '******',
    'response_type' => 'array',
];
$app = Factory::miniProgram($config);
$symfony_request = new SymfonyRequest($request->get(), $request->post(), [], $request->cookie(), [], [], $request->rawBody());
$symfony_request->headers = new HeaderBag($request->header());
$app->rebind('request', $symfony_request);
$appInfo = $app->auth->session("033b050003vd7P19H3100Imad10b050G");
return $appInfo;```
1025 2 1
2个回答

powerbowen

你把参数都打印出来看一下,$request下面那几个

xiuwang

ErrorException: http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated

翻译过来意思是 “http_build_query(): 第二个字符串类型参数传递null是过期的用法”。
说明你用了比较新的php版本,某个地方用了旧的用法。

解决办法:
降级php版本 或者升级相关代码库
具体升级哪个代码库?看报错目录就知道了,报错目录vendor/guzzlehttp/guzzle,说明是 guzzlehttp/guzzle

执行 composer require -W guzzlehttp/guzzle ^7.5.0 升级。当然升级可能不成功,因为EasyWeChat可能写死了guzzlehttp/guzzle版本。那就升级EasyWeChat。EasyWeChat无法升级?那就手动改下报错地方的源码吧。

  • liupeng123456 2022-12-20

    谢谢, 下午的时候已经解决了, 的确得把null改成“”

年代过于久远,无法发表回答
🔝