1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Sime Geo Targeting Script to Increase Amazon Sales

Discussion in 'PHP' started by wannabeme, Jan 16, 2015.

  1. #1
    Here is the code
    
    <?php
    $res=file_get_contents("http://freegeoip.net/json/".get_ip_address());
    $arr=explode(":",$res);
    $seventhparam=explode(",",$arr[8]);
    $countrycode=trim($seventhparam[0]);
    $countrycode=str_replace('"','',$countrycode);
    $countrycode=trim($countrycode,"");
    $asin=$_GET['asin'];
    if($countrycode=="GB")
    {
    $amzurl="http://www.amazon.co.uk/gp/product/".$asin."/?tag=Your UK Tag Here";
    header("Location:".$amzurl);
    }
    else if($countrycode=="CA")
    {
       $amzurl="http://www.amazon.ca/gp/product/".$asin."/?tag=Your CA Tag Here";
    header("Location:".$amzurl);
    }
    else
    {
    $amzurl="http://www.amazon.ca/gp/product/".$asin."/?tag=Your US Tag Here";
    header("Location:".$amzurl);
    }
    function get_ip_address() {
      foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
      if (array_key_exists($key, $_SERVER) === true) {
      foreach (explode(',', $_SERVER[$key]) as $ip) {
      if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
      return $ip;
      }
      }
      }
      }
    }
    ?>
    PHP:
    Save the file as amazon.php and upload it to the root directory of yourdomain.com.Visit yourdomain.com/amazon.php?=ASIN .
     
    wannabeme, Jan 16, 2015 IP
    Alpha_Mental likes this.