API Documentation RunningExamples domain.dns get active records PHP
Aus EUserv Wiki
(Unterschied zwischen Versionen)
Root (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „back to API Documentation = domain.dns_get_active_records = <nowiki> <?php //includes the class library include_once("lib/xmlrpc.inc"); $xmlrpc_internalenco…“) |
Root (Diskussion | Beiträge) |
||
| (Der Versionsvergleich bezieht 1 dazwischenliegende Version mit ein.) | |||
| Zeile 1: | Zeile 1: | ||
| - | back to [[API Documentation]] | + | back to [[API_Documentation#PHP_EXAMPLE_19|API Documentation]] |
= domain.dns_get_active_records = | = domain.dns_get_active_records = | ||
<nowiki> | <nowiki> | ||
<?php | <?php | ||
| + | |||
//includes the class library | //includes the class library | ||
include_once("lib/xmlrpc.inc"); | include_once("lib/xmlrpc.inc"); | ||
$xmlrpc_internalencoding = 'UTF-8'; | $xmlrpc_internalencoding = 'UTF-8'; | ||
| + | |||
$host="api.test.euserv.net"; | $host="api.test.euserv.net"; | ||
$port=443; | $port=443; | ||
| Zeile 12: | Zeile 14: | ||
$api_path="/"; | $api_path="/"; | ||
$domain_id=1337; | $domain_id=1337; | ||
| + | |||
//defines the function | //defines the function | ||
function domain_dns_get_active_records($host,$port,$username,$password,$api_path,$domain_id) | function domain_dns_get_active_records($host,$port,$username,$password,$api_path,$domain_id) | ||
{ | { | ||
| - | //creates the serverurl | + | |
| - | $serverurl = 'https://'.$host.':'.$port.'/'.$api_path; | + | //creates the serverurl |
| - | //----------creates the message which will be send to the server---------- | + | $serverurl = 'https://'.$host.':'.$port.'/'.$api_path; |
| - | //creates the request for the XML-RPC Server | + | |
| - | $request = new xmlrpcmsg('domain.dns_get_active_records'); | + | //----------creates the message which will be send to the server---------- |
| - | //adds parameters to the request | + | |
| - | $request->addParam | + | //creates the request for the XML-RPC Server |
| - | ( | + | $request = new xmlrpcmsg('domain.dns_get_active_records'); |
| - | //creates a value of type struct which contains an array with the username and password | + | |
| - | new xmlrpcval | + | //adds parameters to the request |
| - | ( | + | $request->addParam |
| - | array | + | ( |
| - | ( | + | |
| - | //creates a value of type string which contains the "$username" | + | //creates a value of type struct which contains an array with the username and password |
| - | 'login' => new xmlrpcval($username, 'string'), | + | new xmlrpcval |
| - | //creates a value of type string which contains the "$password" | + | ( |
| - | 'password' => new xmlrpcval($password, 'string'), | + | array |
| - | //creates a value of type string | + | |
| - | 'domain_id' => new xmlrpcval($domain_id), | + | ( |
| - | ) | + | //creates a value of type string which contains the "$username" |
| - | ,'struct' | + | 'login' => new xmlrpcval($username, 'string'), |
| - | ) | + | |
| - | ); | + | //creates a value of type string which contains the "$password" |
| - | //----------creates the XML-RPC client which represent a client of an XML-RPC server---------- | + | 'password' => new xmlrpcval($password, 'string'), |
| - | //creates the client | + | |
| - | $client = new xmlrpc_client($serverurl); | + | //creates a value of type string |
| - | //disable SSL Keycheck | + | 'domain_id' => new xmlrpcval($domain_id), |
| - | $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 | + | ,'struct' |
| - | $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 | + | //----------creates the XML-RPC client which represent a client of an XML-RPC server---------- |
| - | if (0==$response->faultCode()) | + | |
| - | { | + | //creates the client |
| - | //returns the value sent by the server | + | $client = new xmlrpc_client($serverurl); |
| - | $value = $response->value(); | + | |
| - | //returns the actual PHP-language value of "value" | + | //disable SSL Keycheck |
| - | $result_obj = $value->scalarval(); | + | $client->setSSLVerifyPeer(0); |
| - | //destroys "value" | + | |
| - | unset($value); | + | //----------sends the request to the server and gets the response---------- |
| - | } | + | |
| - | else | + | //sends the request via https and writes it into $response. timeout is set to 0 |
| - | { | + | $response = $client->send($request,0,'https'); |
| - | //returns the faultCode and the faultString | + | |
| - | return $error = array ( 'faultCode' => $response->faultCode(), 'faultString' => $response->faultString()); | + | //generates a storable representation of $response and writes it into $result_xml |
| - | } | + | //echo $response->serialize(); |
| - | //destroys "client" | + | |
| - | unset($client); | + | //checks the response. if the method "faultCode" returns zero, the response was succesfull |
| - | //destroys "response" | + | if (0==$response->faultCode()) |
| - | unset($response); | + | { |
| - | //----------reads the result_obj---------- | + | //returns the value sent by the server |
| - | //if result_obj is set then it returns the actual PHP-language value of "result_obj" | + | $value = $response->value(); |
| - | if (isset($result_obj['status'])) | + | |
| - | { | + | //returns the actual PHP-language value of "value" |
| - | $value['status'] = $result_obj['status']->scalarval(); | + | $result_obj = $value->scalarval(); |
| - | } | + | |
| - | if (isset($result_obj['dns_records'])) | + | //destroys "value" |
| - | { | + | unset($value); |
| - | //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 | + | else |
| - | while (list($keyname, $data) = $result_obj['dns_records']->structEach()) | + | { |
| - | { | + | //returns the faultCode and the faultString |
| - | $data = $data->scalarval(); | + | return $error = array ( 'faultCode' => $response->faultCode(), 'faultString' => $response->faultString()); |
| - | //gets the array_keys(members) | + | } |
| - | $keys = array_keys($data); | + | |
| - | $i=0; | + | //destroys "client" |
| - | //counts the arraykeys, the number of arraykeys will be used in the do-while construct | + | unset($client); |
| - | $keysanzahl = count($keys); | + | |
| - | do | + | //destroys "response" |
| - | { | + | unset($response); |
| - | //reads the data and writes it into an array | + | |
| - | $dns_records[$keyname][$keys[$i]] = $data[$keys[$i]]->scalarval(); | + | //----------reads the result_obj---------- |
| - | $i=$i+1; | + | |
| - | } | + | //if result_obj is set then it returns the actual PHP-language value of "result_obj" |
| - | while($i<$keysanzahl); | + | |
| - | } | + | if (isset($result_obj['status'])) |
| - | //writes the array into the array "value" | + | { |
| - | $value['dns_records'] = $dns_records; | + | $value['status'] = $result_obj['status']->scalarval(); |
| - | } | + | } |
| - | return $value; | + | |
| + | if (isset($result_obj['dns_records'])) | ||
| + | { | ||
| + | //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['dns_records']->structEach()) | ||
| + | { | ||
| + | $data = $data->scalarval(); | ||
| + | |||
| + | //gets the array_keys(members) | ||
| + | $keys = array_keys($data); | ||
| + | |||
| + | $i=0; | ||
| + | |||
| + | //counts the arraykeys, the number of arraykeys will be used in the do-while construct | ||
| + | $keysanzahl = count($keys); | ||
| + | do | ||
| + | { | ||
| + | //reads the data and writes it into an array | ||
| + | $dns_records[$keyname][$keys[$i]] = $data[$keys[$i]]->scalarval(); | ||
| + | $i=$i+1; | ||
| + | } | ||
| + | while($i<$keysanzahl); | ||
| + | |||
| + | } | ||
| + | |||
| + | //writes the array into the array "value" | ||
| + | $value['dns_records'] = $dns_records; | ||
| + | } | ||
| + | |||
| + | return $value; | ||
} | } | ||
| + | |||
//calls the function | //calls the function | ||
$result = domain_dns_get_active_records($host,$port,$username,$password,$api_path,$domain_id); | $result = domain_dns_get_active_records($host,$port,$username,$password,$api_path,$domain_id); | ||
| + | |||
if(0==$result['faultCode']) | if(0==$result['faultCode']) | ||
{ | { | ||
| - | echo "Status: ".$result['status']; | + | echo "Status: ".$result['status']; |
| - | //writes the array into "daten" | + | |
| - | $daten = $result["dns_records"]; | + | //writes the array into "daten" |
| - | $datenkeys = array_keys($daten); | + | $daten = $result["dns_records"]; |
| - | $k=0; | + | |
| - | $anzahlkeys = count($datenkeys); | + | $datenkeys = array_keys($daten); |
| - | do | + | |
| - | { | + | $k=0; |
| - | echo " <u>dns_record_id:</u> ".$datenkeys[$k]; | + | $anzahlkeys = count($datenkeys); |
| - | $j=0; | + | |
| - | $datenkeys1 = array_keys($daten[$datenkeys[$k]]); | + | do |
| - | $anzahlkeys1 = count($datenkeys1); | + | { |
| - | do | + | echo " <u>dns_record_id:</u> ".$datenkeys[$k]; |
| - | { | + | |
| - | echo " <br><u>".$datenkeys1[$j]."</u> ".$daten[$datenkeys[$k]][$datenkeys1[$j]]; | + | $j=0; |
| - | echo "<br>"; | + | $datenkeys1 = array_keys($daten[$datenkeys[$k]]); |
| - | $j=$j+1; | + | $anzahlkeys1 = count($datenkeys1); |
| - | } | + | |
| - | while($j<$anzahlkeys1); | + | do |
| - | $k=$k+1; | + | { |
| - | } | + | |
| - | while($k<$anzahlkeys); | + | echo " <br><u>".$datenkeys1[$j]."</u> ".$daten[$datenkeys[$k]][$datenkeys1[$j]]; |
| + | echo "<br>"; | ||
| + | $j=$j+1; | ||
| + | } | ||
| + | while($j<$anzahlkeys1); | ||
| + | |||
| + | $k=$k+1; | ||
| + | } | ||
| + | while($k<$anzahlkeys); | ||
} | } | ||
else | else | ||
{ | { | ||
| - | echo "faultCode: ".$result['faultCode']." faultString: ".$result['faultString']; | + | echo "faultCode: ".$result['faultCode']." faultString: ".$result['faultString']; |
} | } | ||
?> | ?> | ||
</nowiki> | </nowiki> | ||
Aktuelle Version vom 07:53, 6. Sep. 2012
back to API Documentation
domain.dns_get_active_records
<?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="/";
$domain_id=1337;
//defines the function
function domain_dns_get_active_records($host,$port,$username,$password,$api_path,$domain_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.dns_get_active_records');
//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 of type string
'domain_id' => new xmlrpcval($domain_id),
)
,'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['dns_records']))
{
//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['dns_records']->structEach())
{
$data = $data->scalarval();
//gets the array_keys(members)
$keys = array_keys($data);
$i=0;
//counts the arraykeys, the number of arraykeys will be used in the do-while construct
$keysanzahl = count($keys);
do
{
//reads the data and writes it into an array
$dns_records[$keyname][$keys[$i]] = $data[$keys[$i]]->scalarval();
$i=$i+1;
}
while($i<$keysanzahl);
}
//writes the array into the array "value"
$value['dns_records'] = $dns_records;
}
return $value;
}
//calls the function
$result = domain_dns_get_active_records($host,$port,$username,$password,$api_path,$domain_id);
if(0==$result['faultCode'])
{
echo "Status: ".$result['status'];
//writes the array into "daten"
$daten = $result["dns_records"];
$datenkeys = array_keys($daten);
$k=0;
$anzahlkeys = count($datenkeys);
do
{
echo " <u>dns_record_id:</u> ".$datenkeys[$k];
$j=0;
$datenkeys1 = array_keys($daten[$datenkeys[$k]]);
$anzahlkeys1 = count($datenkeys1);
do
{
echo " <br><u>".$datenkeys1[$j]."</u> ".$daten[$datenkeys[$k]][$datenkeys1[$j]];
echo "<br>";
$j=$j+1;
}
while($j<$anzahlkeys1);
$k=$k+1;
}
while($k<$anzahlkeys);
}
else
{
echo "faultCode: ".$result['faultCode']." faultString: ".$result['faultString'];
}
?>

