You are here:  » constructing $URL from affiliate datafeeds


constructing $URL from affiliate datafeeds

Submitted by ukdave on Fri, 2006-07-14 17:16 in

I'm putting a script together that retreivea a live data feed which it does do well however when I prepend the $url variable with my tradedoubler tracking code the script will no longer retreive the details of any two worded items such as "DVD Player".

Does anyone have any idea why this is happening?

Submitted by support on Fri, 2006-07-14 17:18

Hi Dave,

When you're constructing a URL out of two-worded variables you must make sure that you urlencode() the values, otherwise the URL will become broken at the space. Infact, it's good practice to use urlencode() whenever you are constructing a URL even if you don't expect the values to contain spaces.

For example:

$url = "http://www.example.com/getProduct.asp?name=".urlencode($product);

More info:
http://uk.php.net/manual/en/function.urlencode.php

It should then work as expected.

Cheers,
David.

Submitted by ukdave on Fri, 2006-07-14 17:52

Hi Dave, thanks for your help. The top $url below is the one that won't retreive two worded data. All I've done is prepended the tracking data and it no onger works. What do you think have I written it properly?

<?php
// construct Query URL
     //$url  = "http://clkuk.tradedoubler.com/click?p=3431&a=1258053&g=1027266&url=http://export.kelkoo.co.uk/ctl/exportSearch?partner=kelkoo&partnerId=8915497&nbresult=5&offset=1&siteSearchQuery=".urlencode($_GET["siteSearchQuery"])."&catId=".htmlentities($_GET["catId"])."";
     
$url  "http://export.kelkoo.co.uk/ctl/exportSearch?partner=kelkoo&partnerId=8915497&nbresult=5&offset=1&siteSearchQuery=".urlencode($_GET["siteSearchQuery"])."&catId=".htmlentities($_GET["catId"])."";
?>

Submitted by support on Fri, 2006-07-14 18:17

Hi Dave,

I don't have any experience of running Kelkoo URLs through TD, but what i'd try first is this:

<?php
  $kelkoo 
"http://export.kelkoo.co.uk/ctl/exportSearch?partner=kelkoo&partnerId=8915497&nbresult=5&offset=1&siteSearchQuery=".$_GET["siteSearchQuery"]."&catId=".$_GET["catId"];
  
$url "http://clkuk.tradedoubler.com/click?p=3431&a=1258053&g=1027266&url=".urlencode($kelkoo);
?>

Basically, that constructs the Kelkoo URL without any urlencoding; and then it urlencode's the whole lot onto the end of the TD link...

If that doesn't work, the next thing to do is to add some debug code to take a look at the resulting URL and enter it into Internet Explorer directly so that you can see the response for yourself.

This would just be a case of:

<?php
  
print "[".$url."]";exit();
?>

I always print debug values between square brackets so that you can catch any white space that may have crept in - obviously just copy the URL out from between the brackets and paste it into the address bar of IE...

Cheers,
David.

Submitted by ukdave on Fri, 2006-07-14 21:12

Hi David, thanks again.
It turns out that I have been trying to prepend the tracking code to the request url instead of to the merchant url which is returned in the result if that makes sense.

Sorry about that.

On the plus side I learned a bit and got rid of all the unnecessary htmlentities() throughout my script by copying how you had written things out. I'm learning!

Thanks Dave I have really appreciated your expertese.