-
-
Save saber13812002/7f63b73c43ffd53f6038eadba2d1f63c to your computer and use it in GitHub Desktop.
Sample POST request with Guzzle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use GuzzleHttp\Client; | |
$client = new Client([ | |
'base_uri' => 'http://example.com', | |
]); | |
$payload = file_get_contents('/my-data.xml'); | |
$response = $client->post('the/endpoint', [ | |
'debug' => TRUE, | |
'body' => $payload, | |
'headers' => [ | |
'Content-Type' => 'application/x-www-form-urlencoded', | |
] | |
]); | |
$body = $response->getBody(); | |
print_r(json_decode((string) $body)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment