hello,
i have the following if use de code of the bottom
i have the error
HTTP/1.1 401 No ticket Cache-Control: max-age=0 Connection: close Date: Sat, 01 Oct 2016 15:11:36 GMT Pragma: no-cache Server: pve-api-daemon/3.0 Expires: Sat, 01 Oct 2016 15:11:36 GMT bool(true)
if i use my command line then is it fine.
i have the following if use de code of the bottom
i have the error
HTTP/1.1 401 No ticket Cache-Control: max-age=0 Connection: close Date: Sat, 01 Oct 2016 15:11:36 GMT Pragma: no-cache Server: pve-api-daemon/3.0 Expires: Sat, 01 Oct 2016 15:11:36 GMT bool(true)
if i use my command line then is it fine.
Code:
class ProxmoxController extends Controller
{
protected $cookietoken = null;
public function __construct() {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://proxmox.sinkeler.net:8006/api2/json/access/ticket");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"username=root@pam&password=REMOVED");
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 users()
{
$headers = array(
"Cache-Control: no-cache",
'Pragma: no-cache',
);
$string = 'PVEAuthCookie:" '.$this->cookietoken.' " ';
$ch = curl_init();
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, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);
}
}
Last edited by a moderator: