A developer did a custom PHP script for me for importing posts into Wordpress from CSV file. The script worked fine on a staging site, which was on a different server, but when we moved it to my server, it can't download the CSV file and even if I manually import the file to the folder, it won't import it. It doesn't show any errors, just a blank page.
It's a shared hosting, so the provider has set the max_execution_time to 120, which will be enough for the script to run, but it times out on 30 seconds.
The script is using curl_setopt to get the file. The PHP version is 5.5
$userAgent = 'FreeRock.Eu/2.0 (http://www.freerock.eu/share.php)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$address);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 400);
$html = curl_exec($ch);
if (!$html) {
echo "<br /> error number:" .curl_errno($ch);
echo "<br /> error:" . curl_error($ch);
exit;
}
return $html;
}
Then I have:
$z_html = fake_user_agent_http_get('https://www.myfilelocation.com');
$myfile = fopen("promotions.csv", "w") or die("Unable to open file!");
fwrite($myfile, $z_html);
fclose($myfile);
Would appreciate any help here.
Thanks Alexis