I have used and tried below code for getting the xml file from FTP server, Actually that xml file is zipped as accommodation.xml.zip. So that I couldn't get that xml file using curl() in php
$url_method = "ftp://ftp.example.com/accommodation.xml.zip";
$username = "test";
$pwd = "test";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$pwd");
$xmlcontent = gzdecode ( curl_exec($ch) );
curl_close($ch);
print_r($xmlcontent);
By using this code, I have got below error: ////////////////////////// Severity: Warning
Message: gzdecode(): data error
Filename: controllers/cron.php
Line Number: 438 /////////////////////////
But when I try to use the ftp url in browser, that zip file has downloaded.
Can anyone help me to get the xml file using curl() without error ?