Created
August 28, 2013 20:30
-
-
Save danmilleruk/6370834 to your computer and use it in GitHub Desktop.
Convert amazon UK links to a referral tag.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
$tag = "danmil-21"; | |
if($_POST['submit']) | |
{ | |
// Gather variables to store the submitted data and explode the values as needed | |
$url = $_POST['url']; | |
$array = explode("/", "$url"); | |
$ASIN = $array[5]; | |
if($array[4] != "product") { | |
echo "Invalid Amazon URL.<br><strong>MUST</strong> be in the following syntax (HTTP included): <u><strong>http://www.amazon.com/gp/product/B000PLY5BE</strong></u>ref=s9_simh_gw_p147_d0_i3"; | |
} elseif (in_array("www.amazon.com", $array)) { | |
echo "Cannot use amazon.com links"; | |
} else { | |
header("Location: http://www.amazon.co.uk/gp/product/{$ASIN}?ie=UTF8&tag={$tag}&camp=1634&creativeASIN={$ASIN}&linkCode=xm2"); | |
} | |
} | |
?> | |
<h1>Generate Deehem's Amazon Affiliate URL</h1> | |
<form method="post" class="form-horizontal"> | |
<input type="text" name="url"> | |
<input type="submit" name="submit" value="Generate Amazon Link"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment