Ale*_*Per 2 api laravel guzzle postman dingo-api
我创建了一个API,现在我尝试访问该API.邮差一切都很完美,工作正常:
但当我尝试使用guzzle/laravel代码时:
$res3 = $client3->post('https://app.EXAMPLE.com/api/update/'.$serial, [
'headers' => [
'Authorization' => 'Bearer '.$res2['token'],
'Content-Type' => 'application/json'
],
'form_params' => [
'token' => $res2['token'],
'bookingdate' => '07/07/2018 12:00 am',
'notes' => $SpecialRequests
]
]);
Run Code Online (Sandbox Code Playgroud)
我有:
宾语
data:debug:class:"Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException"file:"/ home/user_name/public_html/vendor/dingo/api/src/Auth/Auth.php"line:113
有什么问题?什么在Postman工作,但不适用于Laravel/Guzzle图书馆?
在Postman中,看起来您正在将令牌作为请求参数发送.在您的代码中,看起来您正在使用form_params,它是application/x-www-form-urlencoded.
试试这个:http: //docs.guzzlephp.org/en/stable/quickstart.html#query-string-parameters
$res3 = $client3->post('https://app.EXAMPLE.com/api/update/'.$serial, [
'headers' => [
'Authorization' => 'Bearer '.$res2['token'],
'Content-Type' => 'application/json'
],
'query' => [
'token' => $res2['token'],
'bookingdate' => '07/07/2018 12:00 am',
'notes' => $SpecialRequests
]
]);
| 归档时间: |
|
| 查看次数: |
2353 次 |
| 最近记录: |