请教老师下
我的代码
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class OAuthController extends Controller
{
public function oauth(Request $request){
$http = new \GuzzleHttp\Client;
$response = $http->post('http://various.dev/oauth/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => 5,
'client_secret' => 'bcNyfgMaB6c9oQ5JVSVFHYjGs0JyP6CFYRHi4JGm',
'redirect_uri' => 'http://various-client.dev/callback',
'code' => $request->code
],
]);
return json_decode((string)$response->getBody(),true);
}
}
如果通过浏览器操作报错
Client error: `POST http://various.dev/oauth/token` resulted in a `400 Bad Request` response:
{"error":"invalid_request","message":"The request is missing a required parameter, includes an invalid parameter value, (truncated...)
但同样的参数,如果用postman来post,结果确实正确的,请问是什么原因?