$url = "oauth/connect/token";
try {
$http = new \GuzzleHttp\Client;
$response = $http->post($url, ['form_params' => ['grant_type' => $grant_type, 'client_id' => $client_id, 'client_secret' => $client_secret,
'redirect_uri' => $redirect_uri, 'code' => $code]]);
} catch (\Exception $e) {
Log::info('curl_oauth/connect/token', ['msg' => $e->getMessage(), 'code' => $code, 'time' => date('Y-m-d H:i:s', time())]);
}
$total = json_decode((string) $response->getBody(), true);
//参数拼接
['form_params' => ['grant_type' => $grant_type, 'client_id' => $client_id, 'client_secret' => $client_secret,
'redirect_uri' => $redirect_uri, 'code' => $code]];
laravel curl模拟http进行get和post请求
最新推荐文章于 2025-10-01 02:38:11 发布
本文详细介绍了如何使用OAuth2.0进行授权流程,包括客户端如何通过HTTP客户端库Guzzle向认证服务器发送请求获取访问令牌的过程。文章深入探讨了form_params参数的构造,以及在发生异常时的日志记录方式。

1453

被折叠的 条评论
为什么被折叠?



