Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Http\Request;
  6.  
  7. use App\Http\Requests;
  8.  
  9. class ProxmoxController extends Controller
  10. {
  11. protected $cookietoken = null;
  12.  
  13.  
  14. public function __construct() {
  15. $ch = curl_init();
  16.  
  17. curl_setopt($ch, CURLOPT_URL,"https://url:8006/api2/json/access/ticket");
  18. curl_setopt($ch, CURLOPT_POST, 1);
  19. curl_setopt($ch, CURLOPT_POSTFIELDS,
  20. "username=root@pam&password=");
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  22.  
  23. $server_output = curl_exec ($ch);
  24.  
  25. curl_close ($ch);
  26. $ticket = json_decode($server_output);
  27. $this->cookietoken = $ticket->data->ticket;
  28. }
  29.  
  30. public function test()
  31. {
  32. $headers = array(
  33. "Cache-Control: max-age =0",
  34. 'Pragma: no-cache',
  35.  
  36. );
  37. $string = 'PVEAuthCookie:"'.$this->cookietoken.'"';
  38. $ch = curl_init();
  39. curl_setopt($ch, CURLOPT_VERBOSE, true);
  40. curl_setopt($ch, CURLOPT_URL,"https://proxmox.sinkeler.net:8006/api2/json/access/users");
  41. curl_setopt($ch, CURLOPT_COOKIE, $string );
  42. curl_setopt($ch, CURLOPT_HEADER, " 1L");
  43. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  44. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  45.  
  46. $server_output = curl_exec ($ch);
  47. curl_close ($ch);
  48. var_dump($server_output);
  49.  
  50.  
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement