Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $endpoint_url="your_url_here";
- $string_json = "your_json_string";
- $username="username";
- $password ="password";
- $client = new Client();
- $options= array(
- 'auth' => [
- $username,
- $password
- ],
- 'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json'],
- 'body' => $string_json,
- "debug" => true
- );
- try {
- $res = $client->post($endpoint_url, $options);
- } catch (ClientException $e) {
- echo $e->getRequest() . "\n";
- if ($e->hasResponse()) {
- echo $e->getResponse() . "\n";
- }
- }
- echo "OO<h1>".$res->getStatusCode()."</h1>OO";
Add Comment
Please, Sign In to add comment