Looks good, but have some troubles.
First, I had to fix this condition (in 2 places):
if( ! $result = curl_exec($ch))
if($result != curl_exec($ch))
Second, it is important to give write access to the folder the script is int.
and now just gets empty data:
results.xml:1: parser error : Document is empty
It might be due to my webspace hosters setup, I will try it locally and then on my own Server.
Error hndling could be improved, even if I change my password to a wrong one, it just tells me that the file is empty.