PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Examining Results

The Nirvanix REST API always returns its results in XML. Zend_Service_Nirvanix parses this XML with the SimpleXML extension and then decorates the resulting SimpleXMLElement with a Zend_Service_Nirvanix_Response object.

The simplest way to examine a result from the service is to use the built-in PHP functions like print_r():


<?php
$auth 
= array('username' => 'your-username',
              
'password' => 'your-password',
              
'appKey'   => 'your-app-key');

$nirvanix = new Zend_Service_Nirvanix($auth);
$imfs $nirvanix->getService('IMFS');

$result $imfs->putContents('/foo.txt''fourteen bytes');
print_r($result);
?>

Zend_Service_Nirvanix_Response Object
(
    [_sxml:protected] => SimpleXMLElement Object
        (
            [ResponseCode] => 0
            [FilesUploaded] => 1
            [BytesUploaded] => 14
        )
)

You can access any property or method of the decorated SimpleXMLElement. In the above example, $result->BytesUploaded could be used to see the number of bytes received. Should you want to access the SimpleXMLElement directly, just use $result->getSxml().

The most common response from Nirvanix is success (ResponseCode of zero). It is not normally necessary to check ResponseCode because any non-zero result will throw a Zend_Service_Nirvanix_Exception. See the next section on handling errors.

Zend Framework