Advertisement
Guest User

Untitled

a guest
Nov 25th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. $url = "http://domain.com";
  4.  
  5. $ch = curl_init($url);
  6. curl_setopt($ch, CURLOPT_TIMEOUT, 30); //Timeout after 30 seconds
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8.  
  9. $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //Get status code
  10.  
  11. $response = curl_exec($ch);
  12.  
  13. curl_close($ch);
  14.  
  15. echo $response;
  16.  
  17. ?>
  18.  
  19. <?php
  20.  
  21. $username = "username";
  22. $password = "password";
  23. $url = "https://domain.com/api/v2/orders/count";
  24.  
  25. $ch = curl_init($url);
  26. curl_setopt($ch, CURLOPT_TIMEOUT, 30); //Timeout after 30 seconds
  27. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  28. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  29. curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  30.  
  31. $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //Get status code
  32.  
  33. $response = curl_exec($ch);
  34.  
  35. curl_close($ch);
  36.  
  37. echo $response;
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement