douchuanghan1344 2016-02-05 09:44
浏览 81
已采纳

Guzzle帖子与cookie和数据

Current curl format

curl -v --cookie "JSESSIONID=xxxxxxxxx" -X POST --data "[\"test\",\"password\"]" http://domain.com/register

How do I validate cookie & post the data using Guzzle?

$url = 'http://domain.com/register';
$client = new GuzzleHttp\Client();
$jar = new \GuzzleHttp\Cookie\CookieJar();
$register = $client->post($url, ['cookies' => $jar, 'http_errors' => false]);
  • 写回答

1条回答 默认 最新

  • douzhenggui8171 2016-02-05 12:54
    关注

    Use form_params request option to post data. Use debug request option to compare your request from Guzzle to the curl request.

    There are plenty of examples within SO and the Guzzle documentation explains things very well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?