OK, this one is a bit rough and ready, but it does work. I knocked it together just before Xmas as reading this forum for a couple of month's has persuaded me to try things from the Affiliate end in my "spare" time again.
I've stripped out a lot of the stuff specific to my setup and added comments in. This version deals with the uncompressed files, rather than zips as the server I have it on cannot uncompress zips:
PHP Code:
<?php
// simple Awin feed saver by MatBennett
// save as awingrabber.php (or anything) & call using :
// awingrabber.php?mid=XXX where XXX is the required merchant ID
// change these for your username & password
$userName = "USERNAME";
$userPass = "PASSWORD";
// define locations
$file = 'http://products.affiliatewindow.com/csvproductoutput.php?mid='.$mid.'&user='.$userName.'&password='.$userPass.'&nozip=1';
$destination = 'raw/data'.$mid.'.csv'; // change this for relative path to your desired server location
// retrieve & save the zip file
$fp = fopen($file,"r");
$fp2 = fopen("$destination", "w");
while (!feof($fp)) {
$buf = fread($fp, 1024);
fwrite($fp2, $buf);
}
fclose($fp);
fclose($fp2);
// file will now be saved as: raw/dataXXX.csv where XXX is the merchant ID
?>
This is very simple and just saves the file to your local server. The version that I use cycles through an array of defined merchants then puts the CSV files into a database, but I thought it probably more useful to provide a "stripped down" version.
Don't forget to CHMOD 777 the target directory. Hope that it helps.
Bookmarks