I'm trying to use the vCloud director API for the first time using PHP. This is the first 2 steps in the documentation - https://pubs.vmware.com/vca/index.jsp#com.vmware.vcloud.api.doc_56/GUID-6DC15CF5-3BCF-4426-9988-C71E7A71CBD6.html
Make an API versions request to vCloud Director to obtain the login URL for the REST API.
Use the login URL to create a login session. POST a request to this URL that includes your username, password, and organization name in a MIME Base64 encoding.
However, I can't create a login session using the login information I use in logging in to the vCloud GUI.
Below is my code:
//step 1
$url = 'https://vcloud.test.com/api/versions';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
$oXML = new SimpleXMLElement($result);
$loginURL = null;
foreach($oXML->VersionInfo as $oEntry){
$loginURL = $oEntry->LoginUrl;
break;
}
//step 2
$curl2 = curl_init();
curl_setopt($curl2, CURLOPT_POST, 1);
$loginData = 'api@System:password_here';
$data = base64_encode($loginData);
curl_setopt($curl2, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl2, CURLOPT_URL, $loginURL);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
$result2 = curl_exec($curl2);
curl_close($curl2);
var_dump($result2);
The $result2 only returns false.
Any inputs will be greatly appreciated.
Thanks.