Open goofy-he opened 3 years ago
报错信息提供下
@mingyoung
client middleware $request->getUri()->getQuery()
没有取到值
vendor/mingyoung/dingtalk/src/Kernel/Http/Client.php
public function withAccessTokenMiddleware()
{
if (isset($this->getMiddlewares()['access_token'])) {
return $this;
}
$middleware = function (callable $handler) {
return function (RequestInterface $request, array $options) use ($handler) {
if ($this->app['access_token']) {
parse_str($request->getUri()->getQuery(), $query); // 这个地方没有拿到 code,所以报【不存在的临时授权码】
// 正常情况下,请求参数应该是:access_token=xx&code=xyy
// 现在是,access_token=xx,缺失 code 参数
$request = $request->withUri(
$request->getUri()->withQuery(http_build_query(['access_token' => $this->app['access_token']->getToken()] + $query))
);
}
return $handler($request, $options);
};
};
$this->pushMiddleware($middleware, 'access_token');
return $this;
}
下面这样改,middleware 可以去到值
vendor/mingyoung/dingtalk/src/User/Client.php
public function getUserByCode($code)
{
// return $this->client->get("user/getuserinfo", compact('code')); 源码
return $this->client->get("user/getuserinfo?code={$code}"); // 修改后
}
可以这样解决,
composer require "guzzlehttp/guzzle:^6.3"
overtrue/http
版本的错误
composer remove mingyoung/dingtalk
composer require "mingyoung/dingtalk: ^2.0"
laravel8.0 getUserByCode 不能用,报错 无效码 laravel7 正常