Hello.. I tried using file_get_contents and that causes 500 internal server error (timeout)...
I figured i'd use curl because it gives me more control.
I am having some difficulty.. I want to use curl and have it retrieve the html file. If that url redirects, I want it to follow the redirectio and then retrieve the html contents..
I am passing this url:
http://click.linksynergy.com/fs-bin/click?id=L5X09timNmo&offerid=45359.10000002&type=4&subid=0
and It does follow the redirection properly.. please advise.
THanks.
function getFile($url){
$ch = curl_init(); // create cURL handle (ch)
if (!$ch)
die("Couldn't initialize a cURL handle");
// set some cURL options
$ret = curl_setopt($ch, CURLOPT_HEADER, 1);
$ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$ret = curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// execute
$ret = curl_exec($ch);
if (empty($ret))
{
// some kind of an error happened
die(curl_error($ch));
curl_close($ch); // close cURL handler
}
else
{
$info = curl_getinfo($ch);
curl_close($ch); // close cURL handler
if (empty($info['http_code']))
{
die("No HTTP code was returned");
}
else
{
echo $ret;
}
}
}