Advertisement
Guest User

Untitled

a guest
Feb 4th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // API SERVER INFO
  2. HTTP/1.1 200 OK
  3. Cache-Control: no-cache
  4. Pragma: no-cache
  5. Content-Type: application/json; charset=utf-8
  6. Expires: -1
  7. Server: Microsoft-IIS/7.5
  8. X-AspNet-Version: 4.0.30319
  9. X-Powered-By: ASP.NET
  10. Date: Tue, 19 Jan 2016 11:58:31 GMT
  11. Content-Length: 566
  12.  
  13. // Auth
  14. BASIC auth - username:password
  15.  
  16. // My code:
  17. $username = 'username';
  18. $password = 'password';
  19. $host = 'https://api.some.url';
  20.  
  21. $ch = curl_init();
  22.  
  23. curl_setopt($ch, CURLOPT_URL, $host);
  24. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  25.  
  26.  
  27. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  28. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  29. curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
  30. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  31.  
  32. $result = curl_exec($ch);
  33. $info = curl_getinfo($ch);
  34. curl_close($ch);
  35.  
  36. $data = json_decode($result, true);
  37.  
  38. print_r($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement