API Documentation RunningExample domain.get domain order details PHP

Aus EUserv Wiki

Version vom 09:06, 3. Sep. 2012 bei Root (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

back to API Documentation

domain.get_domain_order_details

 
<?php
//includes the class library
include_once("lib/xmlrpc.inc");
$xmlrpc_internalencoding = 'UTF-8';
$host="api.test.euserv.net";
$port=443;
$username="<API_USER>";
$password="<API_USER_PASSWORD>";
$api_path="/";
$order_id=1337;
//defines the function
function domain_get_domain_order_details($host,$port,$username,$password,$api_path,$order_id)
{
//creates the serverurl
$serverurl = 'https://'.$host.':'.$port.'/'.$api_path;
//----------creates the message which will be send to the server----------
//creates the request for the XML-RPC Server
$request = new xmlrpcmsg('domain.get_domain_order_details');
//adds parameters to the request
$request->addParam
(
//creates a value of type struct which contains an array with the username and password
new xmlrpcval
(
array
(
//creates a value of type string which contains the "$username"
'login' => new xmlrpcval($username, 'string'),
//creates a value of type string which contains the "$password"
'password' => new xmlrpcval($password, 'string'),
//creates a value
'order_id' => new xmlrpcval($order_id, 'int'),
)
,'struct'
)
);
//----------creates the XML-RPC client which represent a client of an XML-RPC server----------
//creates the client
$client = new xmlrpc_client($serverurl);
//disable SSL Keycheck
$client->setSSLVerifyPeer(0);
//----------sends the request to the server and gets the response----------
//sends the request via https and writes it into $response. timeout is set to 0
$response = $client->send($request,0,'https');
//generates a storable representation of $response and writes it into $result_xml
//echo $response->serialize();
//checks the response. if the method "faultCode" returns zero, the response was succesfull
if (0==$response->faultCode())
{
//returns the value sent by the server
$value = $response->value();
//returns the actual PHP-language value of "value"
$result_obj = $value->scalarval();
//destroys "value"
unset($value);
}
else
{
//returns the faultCode and the faultString
return $error = array ( 'faultCode' => $response->faultCode(), 'faultString' => $response->faultString());
}
//destroys "client"
unset($client);
//destroys "response"
unset($response);
//----------reads the result_obj----------
//if result_obj is set then it returns the actual PHP-language value of "result_obj"
if (isset($result_obj['status']))
{
$value['status'] = $result_obj['status']->scalarval();
}
if (isset($result_obj['domain_order_details']))
{
//resets the internal pointer for structEach() to the beginning of the struct
$result_obj['domain_order_details']->structreset();
//reads the keys and values and list returns an array. if no keys and values are read out list returns no array and the while-loop
stops execution
while (list($keyname, $data) = $result_obj['domain_order_details']->structEach())
{
#--->FIRST DIMENSION<---
$domain_order_numbers[$keyname] = $data->scalarval();
$domaindaten = $domain_order_numbers[$keyname];
$z=0;
//gets the array_keys(members)
$domainkeys = array_keys($domaindaten);
//counts the arraykeys, the number of arraykeys will be used in the do-while construct
$anzahldomainkeys = count($domainkeys);
do
{
//reads the first dimension and writes the result in an array
$arraydomaindata[$keyname][$domainkeys[$z]] = $domaindaten[$domainkeys[$z]]->scalarval();
$z=$z+1;
}
while($z<$anzahldomainkeys);
}
//gets the array_keys(members) of "daten"
$daten = $arraydomaindata;
$domainkeys = array_keys($daten);
$k=0;
$anzahldomainorder = count($domainkeys);
#READS THE DATA AND WRITES IT INTO AN ARRAY
do
{
#--->SECOND DIMENSION<---
$x=0;
$arraykeys1 = array_keys($daten[$domainkeys[$k]]);
$anzahlkeys1 = count($arraykeys1);
do
{
#--->THIRD DIMENSION<---
//if value is an array then read each value of this array
if($arraykeys1[$x]=="dns_record_type" OR $arraykeys1[$x]=="redirect_record_type")
{
$y=0;
$arraykeys2 = array_keys($daten[$domainkeys[$k]][$arraykeys1[$x]]);
$anzahlkeys2 = count($arraykeys2);
$subarray1 = $daten[$domainkeys[$k]][$arraykeys1[$x]];
do
{
#--->FOURTH DIMENSION<---
$q=0;
if($arraykeys1[$x]=="redirect_record_type")
{
$subresultarray1[$arraykeys2[$y]] = $subarray1[$arraykeys2[$q]]->scalarval();
}
else
{
$arraykeys3 = array_keys($subarray1[$arraykeys2[$y]]->scalarval());
$anzahlkeys3 = count($arraykeys3);
$subarray2 = $subarray1[$arraykeys2[$y]]->scalarval();
do
{
#--->FIFTH DIMENSION<---
$subresultarray[$arraykeys2[$y]][$arraykeys3[$q]] = $subarray2[$arraykeys3[$q]]->scalarval();
$q=$q+1;
}
while($q<$anzahlkeys3);
}
$y=$y+1;
}
while($y<$anzahlkeys2);
if($arraykeys1[$x]=="redirect_record_type")
{
$resultarray[$domainkeys[$k]][$arraykeys1[$x]] = $subresultarray1;
}
else
{
$resultarray[$domainkeys[$k]][$arraykeys1[$x]] = $subresultarray;
}
}
else
{
$resultarray[$domainkeys[$k]][$arraykeys1[$x]] = $daten[$domainkeys[$k]][$arraykeys1[$x]];
}
$x=$x+1;
}
while($x<$anzahlkeys1);
$k=$k+1;
}
while($k<$anzahldomainorder);
//writes the array into the array "value"
$value['domain_order_details'] = $resultarray;
}
return $value;
}
//calls the function
$result = domain_get_domain_order_details($host,$port,$username,$password,$api_path,$order_id);
if(0==$result['faultCode'])
{
echo "Status: ".$result['status']."<br><br>";
//writes the array into "daten"
$data = $result["domain_order_details"];
//gets the array_keys(members)
$domainkeys = array_keys($data);;
$k=0;
$anzahldomainorder = count($domainkeys);
//AN EXAMPLE HOW YOU CAN READ THE DATA OUT OF THE ARRAY
//the array will be readed in the same procedure like it was already done in the function
//the main difference is that it outputs the data instead of writes it into an array
do
{
echo " <u><h2>".$domainkeys[$k]."</h2></u>";
$x=0;
$arraykeys1 = array_keys($data[$domainkeys[$k]]);
$anzahlkeys1 = count($arraykeys1);
#--->THIRD DIMENSION<---
do
{
//if value is an array then read each value of this array
if($arraykeys1[$x]=="dns_record_type" OR $arraykeys1[$x]=="redirect_record_type")
{
$y=0;
$arraykeys2 = array_keys($data[$domainkeys[$k]][$arraykeys1[$x]]);
$anzahlkeys2 = count($arraykeys2);
$subarray1 = $data[$domainkeys[$k]][$arraykeys1[$x]];
echo "<strong><u>".$arraykeys1[$x]."</u></strong>";
#--->FOURTH DIMENSION<---
do
{
$q=0;
#--->FIFTH DIMENSION<---
if($arraykeys1[$x]=="redirect_record_type")
{
echo "<br><u>".$arraykeys2[$y]."</u>";
echo ": ".$subarray1[$arraykeys2[$q]]."<br>";
}
else
{
$arraykeys3 = array_keys($subarray1[$arraykeys2[$y]]);
$anzahlkeys3 = count($arraykeys3);
$subarray2 = $subarray1[$arraykeys2[$y]];
echo "<br><u>".$arraykeys2[$y]."</u><br>";
do
{
echo $arraykeys3[$q].": ".$subarray2[$arraykeys3[$q]]."<br>";
$q=$q+1;
}
while($q<$anzahlkeys3);
}
$y=$y+1;
}
while($y<$anzahlkeys2);
}
else
{
echo "<strong><u>".$arraykeys1[$x]."</u></strong>: ".$data[$domainkeys[$k]][$arraykeys1[$x]]."<br><br>";
}
$x=$x+1;
}
while($x<$anzahlkeys1);
$k=$k+1;
}
while($k<$anzahldomainorder);
}
else
{
echo "faultCode: ".$result['faultCode']." faultString: ".$result['faultString'];
}
?>