mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
Add PHP example for using the HTTP daemon in docs.
This commit is contained in:
parent
4a6200b055
commit
a34302c88a
1 changed files with 28 additions and 0 deletions
|
|
@ -86,6 +86,34 @@ fetch("http://localhost:8080", requestOptions)
|
||||||
.then(result => console.log(result))
|
.then(result => console.log(result))
|
||||||
.catch(error => console.log('error', error));
|
.catch(error => console.log('error', error));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* `PHP` (Symfony HttpClient)
|
||||||
|
```php
|
||||||
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
||||||
|
class XrechnungValidator
|
||||||
|
{
|
||||||
|
private $httpClient;
|
||||||
|
|
||||||
|
public function __construct(HttpClientInterface $httpClient)
|
||||||
|
{
|
||||||
|
$this->httpClient = $httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
$response = $this->httpClient->request('POST', 'http://localhost:8080', [
|
||||||
|
'headers' => [
|
||||||
|
'Content-Type' => 'application/xml',
|
||||||
|
],
|
||||||
|
'body' => fopen('/path/to/some.xml', 'r'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
echo $response->getContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Status codes
|
## Status codes
|
||||||
| code | description |
|
| code | description |
|
||||||
|-|-|
|
|-|-|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue