Guest User

Untitled

a guest
Mar 6th, 2019
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2. $endpoint_url="your_url_here";
  3. $string_json = "your_json_string";
  4. $username="username";
  5. $password ="password";
  6.  
  7. $client = new Client();
  8. $options= array(
  9. 'auth' => [
  10. $username,
  11. $password
  12. ],
  13. 'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json'],
  14. 'body' => $string_json,
  15. "debug" => true
  16. );
  17. try {
  18. $res = $client->post($endpoint_url, $options);
  19. } catch (ClientException $e) {
  20. echo $e->getRequest() . "\n";
  21. if ($e->hasResponse()) {
  22. echo $e->getResponse() . "\n";
  23. }
  24. }
  25. echo "OO<h1>".$res->getStatusCode()."</h1>OO";
Add Comment
Please, Sign In to add comment