Problem Downloading File With Curl

I am using Curl to get json data, that works well.

I have a need to download a file using Curl. The API requires me to do a GET and pass an ID for the document.

I am uncertain how to deal with the file stream.

At the command line I do a redirect to create the file.




curl -X GET 'http://api.site.com/report-download' > foo.csv



Any suggestions how to deal with the stream? Based on what I understand of the curl function, I believe I want to use




curl -o foo.csv -X GET 'http://api.site.com/report-download' 



In Yii I am doing this:




 $jsonObject = Yii::app()->curl->setOption(CURLOPT_HTTPHEADER=>$auth)->get($report_url);



The extension is great, but not sure it handles this situation or if I need to extend it.

Any help is very appreciated !