Reputation: 377
I would like to use Guzzle to create POST requests, but I do not have cURL installed.
I use the following code:
$handler = new \GuzzleHttp\Handler\StreamHandler();
$client = new GuzzleHttp\Client([
'base_uri' => '...',
'handler' => $handler
]);
$response = json_decode((string) $client->request(
'POST',
'api/ticket/' . $code,
[
'form_params' => [
'name' => $name,
'email' => $email
]
]
)->getBody());
However, this gives me an "Error creating resource: [message] fopen(...): failed to open stream" error message. I am not sure what the problem is.
Upvotes: 0
Views: 1887
Reputation: 5010
First of all, you don't need to select the stream handler manually, Guzzle will do it automatically if cURL is not available.
The error itself most likely means that you try to access a wrong URL. Please, check the resulting URL (base + one from the request).
Upvotes: 1