You are here:  » Trade Doubler Urls

Support Forum



Trade Doubler Urls

Submitted by James Warren on Thu, 2007-01-25 13:26 in

Hi,
Trade Doubler have set me up to use xml feeds and i'm able to use a url to run my automation script.
I have just run the script and that was fine but the auto detected feed format is : [csv|44|0|0]
The feed is an xml format.
Any ideas what has gone wrong?

Thanks.

Submitted by support on Thu, 2007-01-25 13:40

Hello James,

Trade Doubler feeds are gzipped by default - and it is quite possible that a gzipped file would autodetect as CSV. Are you using the download URLs of the following format in your automation script?

http://pf.tradedoubler.com/unlimited/unlimited_pf_aaaa_bbbbbbb.xml.gz

This is how I automate Trade Doubler URLs in my automation script; for example if the above URL is for Coop Electrical shop:

wget -O coop.xml.gz "http://pf.tradedoubler.com/unlimited/unlimited_pf_aaaa_bbbbbbb.xml.gz"
gzip -d coop.xml.gz

After the gzip -d command, the .gz extension is removed leaving the uncompressed file coop.xml.

If this is not the case, another posibility is that white space at the top of the file is causing the auto detect to fail. Trade Doubler feeds have the following format, which you can enter manually in the "Format String" box on the feed registration page step 1:

xml|PRODUCTS/PRODUCT/

Hope this helps,
Cheers,
David.

Submitted by searley on Mon, 2007-01-29 19:12

one way would be to download the non zipped file

example:
http://pf.tradedoubler.com/export/export?export=true&zip=false&a=affidhere&format=xml&programId=50092&pfId=7584

Submitted by James Warren on Tue, 2007-01-30 15:15

Hi, Thanks for the replies.
I still can't unzip the feeds though!
The following is my Automation script, it works fine for unzipped feeds:-

<?php
set_time_limit
(0); // allow unlimited execution time
print "Downloading product feeds ...";
function 
download($file_source$file_target) {
       
$rh fopen($file_source'rb');
       
$wh fopen($file_target'wb');
       if (
$rh===false || $wh===false)  {
// error reading or opening file
            
return true;
        }
        while (!
feof($rh)) {
            if (
fwrite($whfread($rh1024)) ===FALSE)  {
                    
// 'Download error: Cannot write to file ('.$file_target.')';
                    
return true;
                }
        }
        
fclose($rh);
        
fclose($wh);
        
// No error
        
return false;
}
//Trade Doubler Feeds
download(
'http://pf.tradedoubler.com/unlimited/unlimited_pf_6875_1318062.xml.gz','../feeds/AnnSummers.xml');
print 
" done.";
?>

Also, I have an Argos feed from CJ, I have http access but can't automate it as the url changes every update. This is also prefixed .xml.gz
Any ideas?

Thanks for your time and help.

James Warren
http://www.thehighstreetonline.com

Submitted by support on Tue, 2007-01-30 16:04

Hi James,

There's no code in your script to handle unzipping, so this would need to be added. Did you base your script on this thread:

http://www.pricetapestry.com/node/24

If you follow that thread down you will find the code to add to unzip if the necessary programs are installed on your server. Did you see the post above for unzipped TradeDoubler feeds?

I'm not sure what to suggest regarding the Argos feed if the URL changes every time. In this instance, it is always worth contacting merchants to explain that this is a problem and suggest that they keep the same filename!

Cheers,
David.

Submitted by James Warren on Tue, 2007-01-30 17:25

Hi, I did see the above post but the url isn't the same. It's the ''Unlimited,Unlimited"", url.

The script I have is based on the thread, It's the first script posted.
I have read through the whole thread and I can't see any code to add to my existing script.

My php knowlege isn't very good so knowing where to ad any code is difficult for me.

James Warren
http://www.thehighstreetonline.com

Submitted by support on Tue, 2007-01-30 17:30

Hi James,

Are you using a Linux or Windows server?

Submitted by James Warren on Tue, 2007-01-30 17:51

Linux.
I unzipped the Argos file from Cpanel/File Manager.
It's just the Trade doubler feeds.

James Warren
http://www.thehighstreetonline.com

Submitted by support on Tue, 2007-01-30 18:02

Hi James,

I've just made a patch version which is your script, with the fixed code (rather than all the complex testing etc.) to attempt an unzip or gzip on the feed after it has been downloaded.

<?php
set_time_limit
(0); // allow unlimited execution time
print "Downloading product feeds ...";
function 
download($file_source$file_target) {
       
$rh fopen($file_source'rb');
       
$wh fopen($file_target'wb');
       if (
$rh===false || $wh===false)  {
       
// error reading or opening file
            
return true;
        }
        while (!
feof($rh)) {
            if (
fwrite($whfread($rh1024)) ===FALSE)  {
                    
// 'Download error: Cannot write to file ('.$file_target.')';
                    
return true;
                }
        }
        
fclose($rh);
        
fclose($wh);
        
// test to see if $file_target is zipped
        
$filePointer fopen($file_target,"r");
        
$fileHeader fread($filePointer,4);
        
fclose($filePointer);
        if (
$fileHeader == "PK".chr(0x03).chr(0x04))
        { 
          
// try and unzip using unzip
          
$command "/usr/bin/unzip -p ".$file_target." > ".$file_target.".unzipped";
          
exec($command);
          if (
filesize($file_target.".unzipped"))
          {
            
unlink($file_target);
            
rename($file_target.".unzipped",$file_target);
          }
        }
        else
        {
           
// see if the file is gzipped (i.e. tradedoubler)
           // however this cannot be detected from the header
           // so you just have to try....!
          
$command "/usr/bin/gzip -c -d -S \"\" ".$file_target." > ".$file_target.".ungzipped";
          
exec($command);
          if (
filesize($file_target.".ungzipped"))
          {
            
unlink($file_target);
            
rename($file_target.".ungzipped",$file_target);
          }
          else
          {
            
unlink($file_target.".ungzipped");
          }
        }
        
// No error
        
return false;
}
//Trade Doubler Feeds
download(
'http://pf.tradedoubler.com/unlimited/unlimited_pf_6875_1318062.xml.gz','../feeds/AnnSummers.xml');
print 
" done.";
?>

If this works for TradeDoubler, you might find it works for the ones that you can unzip as well, meaning that you won't have to do it through cpanel.

This is down to whether:

* You have permission to run the exec() function on your server
* Your server has unzip and gzip installed in the usual places...

Hope this helps!

Cheers,
David.