1

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]);
4

1 回答 1

0

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.

于 2016-02-05T12:54:21.600 回答