Category Archives: XML-RPC

Parallels Automation use XML-RPC via PHP to get data from system

Parallels Automation is shortly OSS/BSS system which you can integrate , automate everything how you want via APS packages , you can find out more from this link.

I’m so new programming and want to start understand how to communicate/manage with 3th party system with REST API , XML-RPC.  Parallels have a XML-RPC to communicate with it externally alsso i expect to learn PHP with this integration.

Lets start ;

You can find out all Parallels Automation documentation from this link.

At the startup please read what is XML-RPC and how is looks like.

I do not have enough experience about PHP but to find out good explanations about PHP Tools please check the book ” Essential PHP Tools: Modules,Extensions and Acceleratiors”

tcpdump , yes, tcpdump its very very important because after long time i discover that sending wrong things and because of this i couldn’t query the Parallels Automation.  My environment is ; code uploaded to linux server which cpanel run on it , use pear and on the console executed command bellow to understand what XML-RPC request i am sending to RPC Server.

tcpdump -nl -s 0 -A -i eth1 -c 500 port 80
You can see that , your request will appear like below, its important because you will see many many XML-RPC request examples with PHP and every example do not work how you expected because of it i wasted almost a day until think to use debug somehow to see what i am sending (very clever yeah :))) )

Screen Shot 2014-05-30 at 14.39.51
Also i learn a lot about PHP , of course its nothing but its good start for me
First before start need to understand what kind of XML-RPC request i will send to Parallels Automation . Open the API pdf from link i already described above and choose one of method , i choose the method below
First need to read example to what kind of request need to send  what response you will get , use curl from cli with such xml file and memory the request and response.
This is the file ;

vahric:Apicall vahricmuhtaryan$ cat accountdetail.xml

<?xml version=”1.0″ encoding=”UTF-8″ ?>
































this is the curl command from cli

curl –connect-timeout 10 -d @accountdetail.xml -H ‘Content-type:text/xml’

and this is the result

<?xml version=”1.0″ encoding=”UTF-8″?>

<methodResponse><params><param><value><struct><member><name>Result</name><value><array><data><value><array><data><value><i4>1000019</i4></value><value><i4>1</i4></value><value><string>Son Mohican</string></value><value><string>Son Mohican address 1 </string></value><value><string></string></value><value><string>istanbul</string></value><value><string></string></value><value><string>34349</string></value><value><string>tr</string></value><value><string></string></value><value><string>Vahric</string></value><value><string></string></value><value><string>Muhtaryan</string></value><value><string></string></value><value><string>90</string></value><value><string>212</string></value><value><string>3269200</string></value><value><string></string></value><value><string></string></value><value><string></string></value><value><string></string></value><value><string></string></value><value><i4>1401023839</i4></value><value><i4>2</i4></value><value><i4>0</i4></value><value><i4>1</i4></value></data></array></value></data></array></value></member></struct></value></param></params></methodResponse>


Now we have to prepare same request via PHP to query and get same result  , i explained the command inside the code with //
// All usable XML-RPC functions are inside RPC.php , please include it in your code
require_once ‘XML/RPC.php’ ;
// its good to activate/increase the level of error reporting
ini_set(‘display_errors’, true);

//We have to describe RPC server access informations , in this example my RPC Server is and listening 5224, because of related server also work

//for different things generally its url is described RPC2, if you want to know what is RPC2.
$xmlrpc = new XML_RPC_Client( ‘/RPC2’, ‘’, 5224 );

//Need to construct XML-RPC request, you know some Name and Values we have to set

// <struct><member><name>Server</name><value>BM</value></member>
//struct is kind of value type , you can see the its have something inside <member> tags
//new XML_RPC_Value create values
//”Server” => new XML_RPC_Value(“BM”, “string”) is key and value pair and we are using => because of our value type is struct, means Server is key
// BM is value and its type string
// Important part is Params section  , you will see another array is created because get many value inside and all are under <data> tag but you can see that
//There is no <data> tag described like inside accountdetail.xml because its automatically added to request , read

params = array(new XML_RPC_Value(array(

“Server” => new XML_RPC_Value(“BM”, “string”),

“Method” => new XML_RPC_Value(“AccountDetailsGet_API”, “string”),

“Params” => new XML_RPC_Value(


new XML_RPC_Value(1000019, “int”)

), “array”)

),  ‘struct’ ) );

//We almost have same view of accountdetail.xml
//With XML_RPC_Message we %100 construct the accountdetail.xml  file means request , first value Execute is XML-RPC Method, you can see many example

//like XML_RPC_Message(‘system.load’);
$msg = new XML_RPC_Message(‘Execute’,$params);
//Now need to send request to XML-RPC server
$resp = $xmlrpc->send($msg);

//Get the response and out it inside veritable (here i used value as veritable )

$value = $resp->value();

//When you execute the php file you will get response as a object
//object(XML_RPC_Value)#34 (2) {
//                   [“me”]=>
//               array(1) {
//                 [“i4”]=>
//                 string(10) “1401023839”
//               }
//Need to convert object to array to use it
//XML_RPC_decode do it for you
$m = XML_RPC_decode($value);

//You can print it to see

//I told you I’m so new to programming , try to understand key(s) to access array
//you will see that some subarray will be in the result

I learned that array key is Result and all values are under the subarray which key is 0 and i tried to access second element which is the name of the account
echo $m[‘Result’][0][2];

Hope this help to who use PA and need to make XML-RPC query and new programers to discover how to make XML-RPC request(s) with PHP