本文介绍了laravel护照oauth函数,使用curl或guzzle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在api路由文件中有此路由
I have this route in api route file
Route::post('/user/register', 'HomeController@register');
注册功能是
public function register(Request $request)
{
$user = User::create([
...
]);
return $this->getAccessToken($request);
}
public function getAccessToken(Request $request)
{
$url = url('/oauth/token');
$headers = ['Accept' => 'application/json'];
$http = new Client;
$response = $http->post($url, [
'headers' => $headers,
'form_params' => [
'grant_type' => 'password',
'client_id' => 'my_client_id',
'client_secret' => 'my_client_secret',
'username' => 'username',
'password' => 'password'
],
]);
return json_decode((string)$response->getBody(), true);
}
现在,当我将发布请求发送到url时,创建了用户,但请求一直加载且没有响应,整个应用程序都挂起,直到我关闭IDE-phpstorm-我从邮递员向相同的URL /oauth/token
发送相同的参数,并且工作正常.任何帮助或任何人告诉我我所缺少的是什么?
now when I send post request to the url the user is created but the request keep loading and no response and the whole application is hanging until I close the IDE - phpstorm -I send the same parameters to the same url /oauth/token
from postman and it works fine.any help or any one tell me what I am missing ?
推荐答案
问题是当url包含端口
the problem was the curl do not work when the url contains port like
localhost:8000
localhost:8000
这篇关于laravel护照oauth函数,使用curl或guzzle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!