So the whole vcloud api in itself seems a bit complicated and not-so-well documented for what I want to do so I tried to use just a basic HTTP Response class to do this whole process.
I'm following this guide:
http://www.vmware.com/pdf/vcd_15_api_guide.pdf
The error I'm getting: Unexpected HTTP status: 401 Unauthorized
I can login just fine using the vCloud API PHP Class, but using an HTTP authentication it doesn't seem to be working.
Here's my code:
$user = 'myuser@System';
$pswd = 'mypass';
$url = $this->grabUrl();
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2($url,
HTTP_Request2::METHOD_POST, array('ssl_verify_peer' => false, 'use_brackets' => true));
$request->setAuth($user, $paswd);
try {
$response = $request->send();
if (200 == $response->getStatus()) {
echo $response->getBody();
} else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
} catch (HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}