【发布时间】:2019-11-29 11:59:01
【问题描述】:
我正在使用来自 official docs 的护照创建身份验证 api,但我一直无法发送 GuzzelHttp 请求
我做的和文档一模一样,但是当我想用邮递员测试时没有返回结果,它只是不停地加载
这是我的代码 我的控制器
$user = new User();
$user->email = $request->email;
$user->name = $request->name;
$user->password = bcrypt($request->password);
$user->save();
$http = new Client;
$response = $http->post('http://localhost:8000/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => 2,
'client_secret' => 'x2ESrkADoQEaQ91iMW9kKiIvjKo0LL4RxlUtqtmy',
'password' => $request->password
],
]);
dd($response);
return response([
'success'=> true,
'successMessageKey' => 'userCreatedSuccessfully' ,
'data'=>json_decode((string) $response->getBody(), true)
]);
还有我的路线
Route::post('users/register',[
'uses' => 'Api\AuthController@register'
]);
当我运行我的路线时,我没有得到这样的结果并卡在加载中
【问题讨论】:
-
尝试在 Postman 中将其从
raw更改为x-www-form-urlencoded并以这种方式添加参数。 -
我试过但同样的问题:(