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.




