Results 1 to 20 of 20
  1. #1
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    Script for SAS Feed Request
    Hi, I'm looking for a simple script that will download a SAS datafeed, replace the affiliate code with my ID and rename the file with the name of the merchant and save it on the same server.

    Better yet one where I could place more than one feed ID and have it done at once.

    I am not looking for a script that manipulates a database. I already have a program for that which I like. Unfortunately SAS feeds need to be pre-processed.

  2. #2
    What's the word? Rhia7's Avatar
    Join Date
    January 13th, 2006
    Posts
    9,578
    I wish I knew of such a script
    ~Rhia7 -- Remember the 7
    Twitter me

  3. #3
    Member suniliu's Avatar
    Join Date
    March 7th, 2007
    Posts
    162
    There is a site called phpclasses dot org, it has a very large variety of php scripts and classes from around the world, I think you might be able to find what you are looking for there and modify to your needs...

    best wishes...
    - Sunil

    [SIZE=1]The impossibility of today is a hint of what shall be...[/SIZE]

  4. #4
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    Quote Originally Posted by suniliu
    There is a site called phpclasses dot org, it has a very large variety of php scripts and classes from around the world, I think you might be able to find what you are looking for there and modify to your needs...

    best wishes...
    I don't see anything useful on that site.

  5. #5
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    LostDeviant,
    Here is one a use, but it only does one feed at a time. Just use up to step 3 to dl the feed to your server since you'll be processing with another script.

    http://forum.abestweb.com/showthread...d+sas+download
    Someday starts today
    Military Discounts

  6. #6
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    Quote Originally Posted by knight01
    LostDeviant,
    Here is one a use, but it only does one feed at a time. Just use up to step 3 to dl the feed to your server since you'll be processing with another script.

    http://forum.abestweb.com/showthread...d+sas+download
    That script doesn't do what I need at least I don't see where it saves the file with the merchant name after changing the ID. I couldn't get it to run either.
    I'm sure that someone who knows how to program php could modify it so it would work.

  7. #7
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Here is an exact copy of one that works on my server. If it isn't working , what is happening?

    Be sure to put in your sas username, password and id. Also get the merchant number and change the $local_file to whatever you want it named on your server.

    PHP Code:
    <?
    $ftp_server 
    "datafeeds.shareasale.com";
    $ftp_user_name "sasusername";
    $ftp_user_pass "sasuserpass";
    $sasid "sasid";
    $merchid "merchant#";
    $server_file "/$merchid/$merchid.txt";
    $local_file "merchantname.txt";

    // EXECUTE
    echo "<span class='black'>Attempting to make FTP connection...</span><br /><br />";
         
    flush();
         
    sleep(1);

    $conn_id ftp_connect($ftp_server); 
    $login_result = @ftp_login($conn_id$ftp_user_name$ftp_user_pass); 
    if ((!
    $conn_id) || (!$login_result)) { 
         die(
    "<span class='red'>FTP connection has failed to $ftp_server as $ftp_user_name.</span><br /><br />");
    } else { 
         echo 
    "<span class='green'>Connected to $ftp_server successfully as $ftp_user_name.</span><br /><br />"
         
    flush();
         
    sleep(1);


    echo 
    "<span class='black'>Attempting to download datafeed...</span><br /><br />";
         
    flush();
         
    sleep(1);
    if(@
    ftp_get($conn_id$local_file$server_fileFTP_ASCII)) {
         echo 
    "<span class='green'>Successfully downloaded datafeed from $ftp_server as $local_file</span><br /><br />";
         
    flush();
         
    sleep(1);
    } else { 
         die(
    "<span class='red'>FTP download has failed! Script will end.</span><br /><br />");


    ftp_close($conn_id);
    ?>
    Someday starts today
    Military Discounts

  8. #8
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    Hi,
    I tried again. First I got a 500 server error. I re-ran the script. This second time It connected and downloaded the file and saved it with the name. It didn't change the YOURUSERID.

    So something needs to be added so that the id is placed before the file is saved or that the saved file is opened and the ID is replaced.

  9. #9
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Getting closer... try adding this to the end, after the ftp_close line

    PHP Code:
    $datafeed file_get_contents($local_file);
    $fp fopen($local_file"w");
    $replace str_replace("YOURUSERID",$sasid,$datafeed);
    fwrite($fp$replace);
    fclose($fp); 
    Last edited by knight01; March 7th, 2008 at 01:53 AM. Reason: wrong variable
    Someday starts today
    Military Discounts

  10. #10
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    I got the following error:

    Warning: fclose(): supplied argument is not a valid stream resource in /home/myhosting account/public_html/mywebsitedirectory/catalog/csv/script1.php on line 42

    (I edited the error to not show my website info)

  11. #11
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Did you see where I posted the wrong variable? It should be $local_file, not $destination_file. That needs to be corrected in 2 places from the original post.
    Someday starts today
    Military Discounts

  12. #12
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    Quote Originally Posted by knight01
    Did you see where I posted the wrong variable? It should be $local_file, not $destination_file. That needs to be corrected in 2 places from the original post.
    I think it worked that time! Thank you!


    If the file already exists will it be overwritten or do I need to delete it first?

  13. #13
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Cool!

    It should just overwrite the old file.
    Someday starts today
    Military Discounts

  14. #14
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    I just tried with another feed and got the following error:

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16785838 bytes) in /home/webhost/public_html/mywebsite/catalog/csv/petswarehouse.php on line 40

    This looks like a server error any ideas?

  15. #15
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by lostdeviant
    I just tried with another feed and got the following error:

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16785838 bytes) in /home/webhost/public_html/mywebsite/catalog/csv/petswarehouse.php on line 40

    This looks like a server error any ideas?
    Looks like your webhost restricts the size of the files you can open with PHP. You may be able to adjust it with this command at the start of your code:

    ini_set("memory_limit","64M");

    If this doesn't work you'll need to talk to your host about increasing the limit.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  16. #16
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    I'll try both via host support and the script :-) thanks

  17. #17
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    I just finished chatting with Bluehost's support. They raised my memory limit, but they didn't say by how much and it worked. Lets hope it is good for larger feeds like CSN Stores ... ack!

  18. #18
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    You can get round the memory limit problem by loading one line of data at a time.

    PHP Code:
    <?php 
    $fp
    fopen($local_file,"r");
    $fp1 fopen("tempfile""w");
    // read one line at a time
    while ($data=fgets($fp)){
    $replace str_replace("YOURUSERID",$sasid,$data);
    fwrite($fp1,$replace);
    }
    fclose($fp); 
    fclose($fp1);
    // get rid of the tempfile
    copy ("tempfile",$local_file);
    unlink("tempfile");
    ?>

  19. #19
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    Thank you Donk.
    I've swapped that last section of code and it seemed to work with a 22 meg file. I'm waiting for FTP access approval on others to test with larger files. This script will save me so much time and will make my product catalogs much more current.

  20. #20
    ABW Ambassador writerguy's Avatar
    Join Date
    January 17th, 2005
    Location
    Springfield, Missouri, USA
    Posts
    3,248
    I, too, would like to say thanks to all of you in this thread -- heck, in this forum in general. I've found some ideas I didn't know to modify the already modified scripts here to make my use of SAS datafeeds go much better.

    I appreciate the help from you all.
    Generate more fake news.

  21. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Generic feed script?
    By dreamerscove in forum ShareASale - SAS
    Replies: 2
    Last Post: December 8th, 2005, 12:20 PM
  2. Request for InstrumentPro Script
    By nicbos in forum Cusimano.com Scripts
    Replies: 0
    Last Post: May 27th, 2005, 09:23 AM
  3. Script Request
    By world2er in forum Midnight Cafe'
    Replies: 0
    Last Post: February 24th, 2003, 07:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •