Accessing a REST API with PHP
The most obvious omission is error handling. You don't handle curl errors or xml parsing errors.

A REST api is like any other external service you might use in your application (such as a database). You might consider creating a client library for it (first check to see if one does not already exist for the service in question). Example usage with the implementation details neatly tucked away:

&lt;?php
//read these values from your configuration and set here
$connection = array(
    'user' =&gt; '',
    'pass' =&gt; '',
    'baseUrl' =&gt; '',
    'version' =&gt; ''
);
try {
    $client = new FooClient($connection);
    $container = $client-&gt;getContainer('27-95');
    if ($container) {
        //do something with the fetched container
    }

    $sample = $client-&gt;getSample('DOR6A12');
    if ($sample) {
        $sample-&gt;setName('new name');
        $client-&gt;saveSample($sample);
    }
} catch (FooClientException $e) {
    //handle accordingly
}


I'm assuming that the client will return mapped objects for the getContainer and getSample methods. These mapped objects would be instances of php classes which are part of this client library. The xml responses returned by the service would be mapped to to these returned objects. That way, you are not directly dealing with the xml here, rather those details are dealt with in your client library (errors are handled there too with an appropriate exception being thrown if need be).