Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use App\Http\Requests;
- class ProxmoxController extends Controller
- {
- protected $cookietoken = null;
- public function __construct() {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,"https://url:8006/api2/json/access/ticket");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,
- "username=root@pam&password=");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $server_output = curl_exec ($ch);
- curl_close ($ch);
- $ticket = json_decode($server_output);
- $this->cookietoken = $ticket->data->ticket;
- }
- public function test()
- {
- $headers = array(
- "Cache-Control: max-age =0",
- 'Pragma: no-cache',
- );
- $string = 'PVEAuthCookie:"'.$this->cookietoken.'"';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_VERBOSE, true);
- curl_setopt($ch, CURLOPT_URL,"https://proxmox.sinkeler.net:8006/api2/json/access/users");
- curl_setopt($ch, CURLOPT_COOKIE, $string );
- curl_setopt($ch, CURLOPT_HEADER, " 1L");
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $server_output = curl_exec ($ch);
- curl_close ($ch);
- var_dump($server_output);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement