Skip to end of metadata
Go to start of metadata

API integration with PHP

The purpose of this article is to give a basic example of how to use the CDP Server's built in API via PHP. The API will accept XML-RPC call. Details of XML-RPC can  be found ( It is assumed that you have some understanding of how the specification works.

 The client used in this tutorial is PHPXMLRPC. The client library is written in PHP and can be downloaded here: Simply download, un-tar and place the '' in your "include path". By default this is usually (include_path='.:/usr/share/pear:/usr/share/php') unless you have configured otherwise. You can also check/modify the location in your 'php.ini' configuration file.

Let's begin by creating a new client instance (xmlrpc_client) and specifying the necessary URL of the CDP Server along with login credential: 

$r1admin = "admin"; $r1pass = "r1soft"; $client = new xmlrpc_client('http://XXX.XXX.XXX.XXX:8084/xmlrpc'); $client->setCredentials($r1admin, $r1pass);

Once this is done, the script is ready to send the remote call (xmlrpcmsg). For the sake of simplicity, the 'user.addBasicUser' method is being called. Full API documentation is available on the wiki.

String addBasicUser (String username, String emailAddress, String password)

The "xmlrpcmsg" method expects ($methodName, $parameterArray) so the string values must be declared as "new xmlrpcval" values and placed in an array:

$xmlrpc_msg = new xmlrpcmsg('user.addBasicUser', array(         new xmlrpcval($username, 'string'),         new xmlrpcval($emailAddress, 'string'),         new xmlrpcval($password, 'string') ));

Finally, let's send our new message:

$reply = $client->send($xmlrpc_msg);

The client receives the response ($reply) as an object. The response needs to be "cleaned" before it can be printed. Different XML-RPC clients for PHP will handle this differently so please refer to the appropriate documentation for your client. The code to check for (and print) error messages or printing a successful response (new user's UID) is:

if (!$reply) {     print "Could not connect to HTTP server."; } elseif ($reply->faultCode()) {     print "XML-RPC Fault #" . $reply->faultCode() . ": " .         $reply->faultString(); } else  { $uid = $reply->value(); print "The UID is " . $uid->scalarval(); }

Additional Notes: The project was created as a webpage. The script (addBasicUser.php) includes neccessary HTML to capture form inputs and is available for download (To access, click the 'Tools' button in the top right corner).

api api Delete
integration integration Delete
php php Delete
xml-rpc xml-rpc Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.