API Documentation RunningExamples debug.get api version PHP

Aus EUserv Wiki

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
 
(Der Versionsvergleich bezieht 9 dazwischenliegende Versionen mit ein.)
Zeile 1: Zeile 1:
back to [[API_Documentation#PHP_EXAMPLE|API Documentation]]
back to [[API_Documentation#PHP_EXAMPLE|API Documentation]]
= debug.get_api_version =
= debug.get_api_version =
-
   <code>
+
   <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 11: Zeile 13:
$password="<API_USER_PASSWORD>";
$password="<API_USER_PASSWORD>";
$api_path="/";
$api_path="/";
 +
//defines the function
//defines the function
function debug_get_api_version($host,$port,$username,$password,$api_path)
function debug_get_api_version($host,$port,$username,$password,$api_path)
{
{
-
//creates the serverurl
+
 
-
$serverurl = 'https://'.$host.':'.$port.'/'.$api_path;
+
 
-
//----------creates the message which will be send to the server----------
+
  //creates the serverurl
-
//creates the request for the XML-RPC Server
+
  $serverurl = 'https://'.$host.':'.$port.'/'.$api_path;
-
$request = new xmlrpcmsg('debug.get_api_version');
+
 
-
//adds parameters to the request
+
  //----------creates the message which will be send to the server----------
-
$request->addParam
+
 
-
(
+
  //creates the request for the XML-RPC Server
-
//creates a value of type struct which contains an array with the username and password
+
  $request = new xmlrpcmsg('debug.get_api_version');
-
new xmlrpcval
+
 
-
(
+
  //adds parameters to the request
-
array
+
  $request->addParam
-
(
+
    (
-
//creates a value of type string which contains the "$username"
+
   
-
'login' => new xmlrpcval($username, 'string'),
+
    //creates a value of type struct which contains an array with the username and password
-
//creates a value of type string which contains the "$password"
+
    new xmlrpcval
-
'password' => new xmlrpcval($password, 'string')
+
      (
-
)
+
      array
-
,'struct'
+
 
-
)
+
      (
-
);
+
        //creates a value of type string which contains the "$username"
-
//----------creates the XML-RPC client which represent a client of an XML-RPC server----------
+
        'login' => new xmlrpcval($username, 'string'),
-
//creates the client
+
       
-
$client = new xmlrpc_client($serverurl);
+
        //creates a value of type string which contains the "$password"
-
//disable SSL Keycheck
+
        'password' => new xmlrpcval($password, 'string')
-
$client->setSSLVerifyPeer(0);
+
      )
-
//----------sends the request to the server and gets the response----------
+
      ,'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
//sends the request via https and writes it into $response. timeout is set to 0
-
$response = $client->send($request,0,'https');
+
  $response = $client->send($request,0,'https');
-
//generates a storable representation of $response and writes it into $result_xml
+
 
-
//$result_xml = $response->serialize();
+
  //generates a storable representation of $response and writes it into $result_xml
-
//checks the response. if the method "faultCode" returns zero, the response was succesfull
+
  //$result_xml = $response->serialize();
-
if (0==$response->faultCode())
+
 
-
{
+
  //checks the response. if the method "faultCode" returns zero, the response was succesfull
-
//returns the value sent by the server
+
  if (0==$response->faultCode())  
-
$value = $response->value();
+
    {
-
//returns the actual PHP-language value of "value"
+
      //returns the value sent by the server
-
$result_obj = $value->scalarval();
+
      $value = $response->value();
-
//destroys "value"
+
     
-
unset($value);
+
      //returns the actual PHP-language value of "value"
-
}
+
      $result_obj = $value->scalarval();
-
else
+
     
-
{
+
      //destroys "value"
-
//returns the faultCode and the faultString
+
      unset($value);    
-
return $error = array ( 'faultCode' => $response->faultCode(), 'faultString' => $response->faultString());
+
    }
-
}
+
    else
-
//destroys "client"
+
    {
-
unset($client);
+
      //returns the faultCode and the faultString
-
//destroys "response"
+
      return $error = array ( 'faultCode' => $response->faultCode(), 'faultString' => $response->faultString());
-
unset($response);
+
    }
-
//----------reads the result_obj----------
+
   
-
//if result_obj is set then it returns the actual PHP-language value of "result_obj"
+
  //destroys "client"
-
if (isset($result_obj['status']))
+
  unset($client);
-
{
+
   
-
$value['status'] = $result_obj['status']->scalarval();
+
  //destroys "response"
-
}
+
  unset($response);
-
if (isset($result_obj['api_version']))
+
 
-
{
+
  //----------reads the result_obj----------
-
$value['api_version'] = $result_obj['api_version']->scalarval();
+
   
-
}
+
  //if result_obj is set then it returns the actual PHP-language value of "result_obj"
-
return $value;
+
   
 +
  if (isset($result_obj['status']))
 +
  {
 +
    $value['status'] = $result_obj['status']->scalarval();
 +
  }
 +
  if (isset($result_obj['api_version']))
 +
  {
 +
    $value['api_version'] = $result_obj['api_version']->scalarval();
 +
  }  
 +
  return $value;
 +
   
}
}
 +
//calls the function
//calls the function
$result = debug_get_api_version($host,$port,$username,$password,$api_path);
$result = debug_get_api_version($host,$port,$username,$password,$api_path);
 +
if(0==$result['faultCode'])
if(0==$result['faultCode'])
{
{
-
echo "Status: ".$result['status']." API-Version: ".$result['api_version'];
+
  echo "Status: ".$result['status']."   API-Version: ".$result['api_version'];
}
}
else
else
{
{
-
echo "faultCode: ".$result['faultCode']." faultString: ".$result['faultString'];
+
  echo "faultCode: ".$result['faultCode']." faultString: ".$result['faultString'];
}
}
?>
?>
-
   </code>
+
   </nowiki>

Aktuelle Version vom 07:20, 6. Sep. 2012

back to API Documentation

debug.get_api_version

 
<?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="/";

//defines the function
function debug_get_api_version($host,$port,$username,$password,$api_path)
{


  //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('debug.get_api_version');
  
  //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')
      )
      ,'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
  //$result_xml = $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['api_version']))
  {
    $value['api_version'] = $result_obj['api_version']->scalarval();
  }    
  return $value;
    
}

//calls the function
$result = debug_get_api_version($host,$port,$username,$password,$api_path);

if(0==$result['faultCode'])
{
  echo "Status: ".$result['status']."   API-Version: ".$result['api_version'];
}
else
{
  echo "faultCode: ".$result['faultCode']." faultString: ".$result['faultString'];
}
?>