【发布时间】:2016-08-30 17:59:50
【问题描述】:
我有一个 curl 命令
curl -i -k https://anAddress.com/web/publication/add -d '{"title”:"uniqueIdxxxxxxx"}' -uexpress:Test0099887766 -H"Content-Type: application/json" -X POST
我需要在 laravel 中运行这个 CURL 命令。我尝试使用 guzzle:
$client = new Client();
$res = $client->request('POST', 'https://annAddress.com/web/publication/add', [
'form_params' => [
'title' => 'xc123',
]
]);
$result= $res->getBody();
dd($result);
但我只是得到一个错误:
TooManyRedirectsException in RedirectMiddleware.php line 141:
Will not follow more than 5 redirects
【问题讨论】:
-
看起来响应将重定向发送到同一页面。 curl 命令的完整响应是什么?
-
我很高兴遇到这个问题,因为我什至没有听说过 Guzzle。它的文档在这里:github.com/guzzle/guzzle 当我需要将数据发布到 URL 时,我会尝试在 Laravel 中使用它。
标签: php laravel curl laravel-5.2 guzzle