Hi,
I have a site which lists products via 3rd party affiliate links. The links are displayed on my site via PHP, I wish to mask the url so it appears to be on my domain, instructions have been provided and implemented but for some reason, the links only work one time then rather than redirecting to the 3rd party site, they redirect to my homepage, as if some sort of Curl or PHP or server caching is taking place.
Here's the documentation:
/*
Retrieve HTML for [login to view URL] product unit.
Note: 'fopen wrappers' must be enabled. Requires PHP 4.3.0. or above.
*/
/*
Code by Bob DeVeaux for ECU
This re-writes the ECU link to the same domain as the code
*/
// function for downloading file
function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 5000);
curl_setopt($c, CURLOPT_TIMEOUT, 10000);
$contents = curl_exec($c);
curl_close($c);
if ($contents)
{
return $contents;
}
else
{
return false;
}
}
$ecu_mid = 839; // your member id
$ecu_uid = 20212; // your unit id
$ecu_tracking = ''; // optional tracking id
$ecu_keywords = ''; // optional keywords for random product unit
$ecu_debug_mode = 'no'; // debug mode (yes or no)
$domain = "http://".$_SERVER["HTTP_HOST"];
$path = '/blog';
$ecu_url =
'[login to view URL]'.$ecu_mid
.'&ecu_uid='.$ecu_uid.'&ecu_tracking='.urlencode($ecu_tracking).
'&ecu_keywords='.urlencode($ecu_keywords).'&debug='.$ecu_debug_mode;
// cURL download file.
if($content = curl_get_file_contents($ecu_url))
{
$content = str_replace('href="[login to view URL]',
'href="'.$domain.$path, $content);
print $content;
}
I then create a [login to view URL] file containing the following:
$domain = "http://".$_SERVER["HTTP_HOST"];
$qs = explode('[login to view URL]', $_SERVER['REQUEST_URI']);
$url = '[login to view URL]'.$qs[1];
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".$url);
And amend [login to view URL] to include:
Disallow: /PATH_HERE/[login to view URL]
Like I say, it appears to work, and does so on first clicks, but from then on, it doesn't work due to cache or something?!
Thanks,
Peter.