I've tried to implement the code david supplied for the linkshare feed on this thread: http://www.pricetapestry.com/node/2653. Unfortunately I keep getting the unsuccessful error. I'm able to login, but not get past line 22 of the code. I think I need a merchant.txt file. It doesn't exist when I remotely FTP into the linkshare server. Any ideas? What is contained in that file?
Thanks. I think I may be running into a problem because I don't have the two .php files that start the code in the first few lines. I checked on the linkshare site and didn't see anything. Can you refer me to that thread in these forums?
Hi Lunen,
They're actually just left over from an alternative import script (nothing to do with Price Tapestry) which that user was running. If you're only needing to use the script to download the files simply delete those require() lines and that should prevent any errors.
Alternatively of course, if presumably you know the filenames that you are trying to fetch you can look at implementing within an automation script, using wget to fetch the feeds on a regular basis as described in this thread...
Any problems of course just let me know...
Cheers,
David.
--
PriceTapestry.com
David, Is works! Thank you so much. This will save me a lot of time. I don't know why LS makes it so hard. Is there an easy way to add a line of code to change the file name? All the files have numbers and it's hard to keep track of them.
Hi Lunen,
It's straight forward to add a section of code at the end that will rename the numeric files into merchant names. Have a go with something like this, adding as many $newNames array entries as you require, just before the closing PHP tag...;
$newnames["1234.txt"] = "Merchant1.txt";
$newnames["5678.txt"] = "Merchant2.txt";
foreach($newnames as $oldname => $newname)
{
rename("feeds/".$oldname,"feeds/".$newname);
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
As I add more merchants to the merchants.txt file I get the unsuccessful error. It worked the first few times and now I get the Error. I have about 30 merchants listed. Is that the problem?
Hi Lunen,
Try adding on the first line of your script (after the opening PHP tag):
set_time_limit(0);
Cheers,
David.
--
PriceTapestry.com
I tried that and it doesn't do it. I also set all the folders and merchants.txt file to 777. It doesn't seem like it's getting into the resource intensive part of the script for it's unsuccessful. Maybe it's my merchants.txt file.
Hi Lunen,
It might be worth printing out the $datafeed_file causing the unsuccessful message, and also removing the exit(); statement which would at least let the script continue. In the code, look for this section:
if (!$success=ftp_fget($conn,$fp,$datafeed_file,FTP_BINARY))
{
echo "unsuccessful";
ftp_quit($conn);
exit;
}
...and REPLACE with..
if (!$success=ftp_fget($conn,$fp,$datafeed_file,FTP_BINARY))
{
echo "transferring ".$datafeed_file." unsuccessful<br />";
}
It may be something in merchants.txt (pre or post amble) causing the problem - the above should help identify it...
Cheers,
David.
--
PriceTapestry.com
David, as always you rock! that did it. As it turns out, some of the datafeed files were empty, OKb. I think that's why the script kept ending with "unsuccessful". Thanks again.
Hi lunen,
merchants.txt is a local file (in the same folder as your script, which needs to be your Price Tapestry installationm folder, as the script later refers to "feeds/") which contains a pipe separated list of the files you want the script to fetch from your Linkshare FTP account, for example:
merchant1.csv.gz|merchant2.csv.gz|merchant3.csv.gz|etc.
(i'm not sure exactly what file naming convention LinkShare use, but you can see the exact filenames required if you login manually via FTP)
Note that the script requires a temp/ folder, which needs to be writable by PHP, as does your feeds/ folder. The easiest way to make these writable is via your FTP program - right click on the folders in the remote window and look for "Permissions" or maybe "Properties" and then "Permissions", and give WRITE access to all users (owner/group/world).
Hope this helps!
Cheers,
David.
--
PriceTapestry.com