Page 1 of 2 12 LastLast
Results 1 to 25 of 40
  1. #1
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Automated FTP of my Current SAS Database?
    I am sure this can be done, but I haven't spent the time figuring it out. I would like to automatically FTP the file of just the current coupons for my merchants.

    Quick Database of all available coupons - ONLY CURRENT (Your merchants only)


    Normally, I would click on this link...

    htt p://www .shareasale. com/a-dealbuilder.cfm?allmymerchants&current=1

    which would take me to this link....

    htt p://www. shareasale. com/a-reportcsv-new2.cfm

    where I could saved the file to my PC. Is there a way to retrieve this file so I can just add it to my daily cronjobs?

  2. #2
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    Man Seymour you are as lazy as I am. I've been thinking of asking the same thing.


  3. #3
    ABW Ambassador meadowmufn's Avatar
    Join Date
    January 18th, 2005
    Location
    Seattle
    Posts
    2,587
    I was wondering that too recently. You can get the deals database via FTP, but it's ALL the current deals, not just the ones with your merchants.
    -Don't criticize anyone til you've walked a mile in their shoes. Then when you do criticize them, you'll be a mile away and have their shoes.
    - Silence is golden. Duct Tape is silver.

  4. #4
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Quote Originally Posted by meadowmufn
    I was wondering that too recently. You can get the deals database via FTP, but it's ALL the current deals, not just the ones with your merchants.
    And how is that done? It may be better than nothing.

  5. #5
    ABW Ambassador meadowmufn's Avatar
    Join Date
    January 18th, 2005
    Location
    Seattle
    Posts
    2,587
    It should be here:

    datafeeds.shareasale.com/dealdatabase/dealdatabase.txt

    Shouldn't be too hard to filter out merchants that you're not affiliate with.
    -Don't criticize anyone til you've walked a mile in their shoes. Then when you do criticize them, you'll be a mile away and have their shoes.
    - Silence is golden. Duct Tape is silver.

  6. #6
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by bumpaw
    Man Seymour you are as lazy as I am. I've been thinking of asking the same thing.
    This is definitely not a case of laziness and more a case of efficiency. Manually doing anything with a datafeed is a major bottleneck. Maybe submit a ticket and see what SAS can set up for your FTP.

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

  7. #7
    Lite On The Do, Heavy On The Nuts Donuts's Avatar
    Join Date
    January 18th, 2005
    Location
    Winter Park, FL
    Posts
    6,930
    then come back here and share... :-)

  8. #8
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    Here's a quick (messy) piece of code for you to build on:

    PHP Code:
    <pre>
    <?php
    $mymerchants
    =array(13111,14440);
    $xml simplexml_load_file('http://www.shareasale.com/dealdatabase2.xml');
    foreach (
    $xml->channel->item as $key=>$value){
    if (
    in_array($value->merchantID,$mymerchants)){
    print_r($value);
    }
    }
    ?>
    </pre>
    Just add your merchants to $mymerchants (separated by commas).

  9. #9
    ABW Ambassador meadowmufn's Avatar
    Join Date
    January 18th, 2005
    Location
    Seattle
    Posts
    2,587
    Quote Originally Posted by Donk
    Here's a quick (messy) piece of code for you to build on:

    PHP Code:
    <pre>
    <?php
    $mymerchants
    =array(13111,14440);
    $xml simplexml_load_file('http://www.shareasale.com/dealdatabase2.xml');
    foreach (
    $xml->channel->item as $key=>$value){
    if (
    in_array($value->merchantID,$mymerchants)){
    print_r($value);
    }
    }
    ?>
    </pre>
    Just add your merchants to $mymerchants (separated by commas).
    Thanks, Donk. I was going to come back here and post my solution, but you pretty much did it for me.
    -Don't criticize anyone til you've walked a mile in their shoes. Then when you do criticize them, you'll be a mile away and have their shoes.
    - Silence is golden. Duct Tape is silver.

  10. #10
    http and a telephoto
    Join Date
    January 18th, 2005
    Location
    NYC
    Posts
    17,708
    Somebody wanna 'splain that in english?
    Deborah Carney
    TeamLoxly.com BookGoodies.com ABCsPlus.com

  11. #11
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    The SAS deal database is a list of coupons available for all SAS merchants.

    My piece of code creates a listing of the deals for the selected merchants in PHP.

    As I said the listing is a bit messy but will allow people with a fairly basic knowledge of PHP to create an HTML page or add the data to a database.

    I can elaborate on the code later unless someone beats me to it.

    Bob

  12. #12
    http and a telephoto
    Join Date
    January 18th, 2005
    Location
    NYC
    Posts
    17,708
    Thanks, I am sure there are plenty of people that are confused and would like to know how to use the code

    So that code goes on a php page like an include? And it will call and show the deals from a merchant, with the affiliate coded url?
    Deborah Carney
    TeamLoxly.com BookGoodies.com ABCsPlus.com

  13. #13
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by loxly
    Thanks, I am sure there are plenty of people that are confused and would like to know how to use the code

    So that code goes on a php page like an include? And it will call and show the deals from a merchant, with the affiliate coded url?
    It'll just display all of the content for each XML item in raw form, but it won't be formatted, sorted, etc. This is best used for inserting into a database, but even that would require some additions to the code.

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

  14. #14
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    Here is the code to get the deals into a database.

    Create the table (change the table name from test to your table name)
    Code:
    CREATE TABLE `test` (
      `title` varchar(255) NOT NULL,
      `link` varchar(255) NOT NULL,
      `guid` varchar(255) NOT NULL,
      `pubDate` varchar(255) NOT NULL,
      `description` text NOT NULL,
      `dealstartdate` date NOT NULL,
      `dealenddate` date NOT NULL,
      `dealpublishdate` date NOT NULL,
      `dealeditdate` date NOT NULL,
      `couponcode` varchar(255) NOT NULL,
      `trackingurl` varchar(255) NOT NULL,
      `restrictions` varchar(255) NOT NULL,
      `keywords` varchar(255) NOT NULL,
      `category` varchar(255) NOT NULL,
      `commissionpercentage` varchar(255) NOT NULL,
      `merchantID` bigint(6) NOT NULL,
      `merchantname` varchar(255) NOT NULL,
      `dealtitle` varchar(255) NOT NULL,
      `imagebig` varchar(255) NOT NULL,
      `imagesmall` varchar(255) NOT NULL,
      `htmlofdeal` text NOT NULL
    ) ENGINE=MyISAM ;
    Now here is the php code:
    Change the $SASID and the database connection variables to your own.
    If you want all merchants use $mymerchants=array("All"); If you want to specify only your own merchants use $mymerchants=array(13111,14440); add the SAS merchant ids separated by commas.

    PHP Code:
    <?php
    // Insert your userdata
    $SASID=12345;
    $dbase="";
    $dealstable="test";
    $dbhost="localhost";
    $dbuser="";
    $dbpassword="";
    //list you merchants
    $mymerchants=array(13111,14440);
    // or uncomment the next line for all merchants
    //$mymerchants=array("All");
    //If you don't use all fields in the database edit this array
    $fields=array(
    "title",
    "link",
    "guid",
    "pubDate",
    "description",
    "dealstartdate",
    "dealenddate",
    "dealpublishdate",
    "dealeditdate",
    "couponcode",
    "trackingurl",
    "restrictions",
    "keywords",
    "category",
    "commissionpercentage",
    "merchantID",
    "merchantname",
    "dealtitle",
    "imagebig",
    "imagesmall",
    "htmlofdeal"
    );
    $xml simplexml_load_file('http://www.shareasale.com/dealdatabase2.xml');
    $i=0;
    foreach (
    $xml->channel->item as $key=>$value){
    if (
    in_array($value->merchantID,$mymerchants)or $mymerchants[0]=="All"){
    $item[$i]=get_object_vars($value);
    foreach (
    $item[$i] as $key1=>$value1){
    if (
    is_object($item[$i][$key1]))$item[$i][$key1]=implode(",",get_object_vars($value1));
    //correct date formats
    if (stristr($key1,"date")){
    $temp=explode("/",$item[$i][$key1]);
    $item[$i][$key1]=$temp[2]."-".$temp[0]."-".$temp[1];
    }
    //get rid of http:// without url in images
    if (stristr($key1,"image") and trim(str_replace("http://","",$item[$i][$key1]))=="")$item[$i][$key1]="";
    //add tracking
    if ($key1=="trackingurl")$item[$i][$key1]= str_replace("YOURUSERIDHERE",$SASID,$item[$i][$key1]); 
    // This section cleans the c**p the some merchants claim is html
    // Perhaps it would be better to use strip_tags($item[$i][$key1]) instead
    if ($key1=="htmlofdeal") {
    $tidy_html=tidy_parse_string($item[$i][$key1]);
    $tidy_html=tidy_get_body($tidy_html);
    $tidy_html=$tidy_html->value;
    $tidy_html=str_replace("<body>","",$tidy_html);
    $tidy_html=trim(str_replace("</body>","",$tidy_html));
    $item[$i][$key1]=$tidy_html;
    }
    }
    $i++;
    }
    }
    // you've got the data put it into mysql;
    //There is no obvious key so delete the old database first
    $link=mysql_connect($dbhost,$dbuser,$dbpassword);
    mysql_select_db($dbase);
    mysql_query("TRUNCATE TABLE `$dealstable` ");
    $today=date("Y-m-d",time());
    foreach (
    $item as $key=>$value){
    //Only accept currnt coupons 
    if ($value['dealstartdate']<$today and $value['dealenddate'] >$today){
    $sql="INSERT INTO $dealstable VALUES (";
    foreach (
    $fields as $key1=>$field){
    $sql.="'$value[$field]',";
    }
    // clear the last comma
    $sql=substr($sql,0,-1);
    $sql.=");";
    mysql_query$sql);
    }
    }
    ?>
    Now youv'e got the deals in a database you'll have to work out how to display them

  15. #15
    Newbie ice5nake's Avatar
    Join Date
    July 21st, 2008
    Location
    Emigsville, Pa
    Posts
    3
    Is there a datafeed available that is the IDs of my current merchants? That could make for a usable combination with dealdatabase.txt.

  16. #16
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    That is a great script Donk! I was finally brave enough to try it this afternoon.

  17. #17
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    No problems Lostdeviant happy to help.

    ice5nake if you log into SAS. Go to Links -> Get a Link/Banner. Scroll down and check the "Create Downloadable Text File:" and refresh report. You will get a pipe separated list of all your merchants. Upload the file to the server. Then use this code in place of the "$mymerchants=array(13111,14440); " line.


    PHP Code:
    $i=0;
    $fp=fopen("a-12345.txt","r");
    while (
    $data=fgetscv($fp,8192,"|")){
    $merchant[$i]=$data[0];
    $i++;
    }
    $mymerchants=implode(",",$merchant);
    fclose($fp); 

  18. #18
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Quote Originally Posted by Donk
    No problems Lostdeviant happy to help.

    ice5nake if you log into SAS. Go to Links -> Get a Link/Banner. Scroll down and check the "Create Downloadable Text File:" and refresh report. You will get a pipe separated list of all your merchants. Upload the file to the server. Then use this code in place of the "$mymerchants=array(13111,14440); " line.


    PHP Code:
    $i=0;
    $fp=fopen("a-12345.txt","r");
    while (
    $data=fgetscv($fp,8192,"|")){
    $merchant[$i]=$data[0];
    $i++;
    }
    $mymerchants=implode(",",$merchant);
    fclose($fp); 
    In case anyone just copy and paste the code that Donk just posted above, without checking it first, note that the fgetscv have a typo, it should be fgetcsv instead.

    And btw, the entire script that Donk posted on post #14 works right out of the box as is, so it should solve some of the problems some of us may have encounter before, on how to use the SAS xml dealdatabase.

    Good job Donk, thanks for sharing the code with everyone.

  19. #19
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    It looks like this thread forked at post #8. SeymourButts spelled out his question very clearly and I have had the same question. To me his question is still unanswered.
    PHP Code:
    $xml simplexml_load_file('http://www.shareasale.com/dealdatabase2.xml'); 
    I have never used the xml feed this way but do subscribe to it and access it via Google Reader. It appears to be way more complicated to get the deals this way.

    At AvantLink the steps that SeymourButts outlined are all rolled up in one URI that you create in their interface. Run that URI through CRON or whatever and my database is updated. That's the solution I was hoping for here from SAS.


  20. #20
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    I posted a help ticket asking for this to be an Added Feature. It shouldn't be hard but I know they are busy.


  21. #21
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Quote Originally Posted by bumpaw
    I posted a help ticket asking for this to be an Added Feature. It shouldn't be hard but I know they are busy.
    Thanks for doing that.

  22. #22
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    After connecting to my database while running the script with ...

    $i=0;
    $fp=fopen("a-mysasnumber.txt","r");
    while ($data= fgetcsv($fp,8192,"|")){
    $merchant[$i]=$data[0];
    $i++;
    }
    $mymerchants= implode(",",$merchant);
    fclose($fp);


    ... I get the following error:

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/myhostingaccount/public_html/mysite/myscriptdirectory/scriptname.php on line 111

    line 111 is:

    if (in_array($value->merchantID,$mymerchants)or $mymerchants[0]=="All"){


    any ideas?

    I assume the second argument is "$mymerchants" which is what was changed.
    Last edited by lostdeviant; July 30th, 2008 at 12:25 PM. Reason: no need to share my sas id

  23. #23
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    Sorry my mistake

    That will teach me to post code without checking it first.

    The code should be:


    PHP Code:
    $i=0;
    $fp=fopen("a-mysasnumber.txt","r");
    while (
    $datafgetcsv($fp,8192,"|")){
    $mymerchants[$i]=$data[0];
    $i++;
    }
    fclose($fp); 
    Hope that helps.

    Bob

  24. #24
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by lostdeviant
    After connecting to my database while running the script with ...

    $i=0;
    $fp=fopen("a-mysasnumber.txt","r");
    while ($data= fgetcsv($fp,8192,"|")){
    $merchant[$i]=$data[0];
    $i++;
    }
    $mymerchants= implode(",",$merchant);
    fclose($fp);


    ... I get the following error:

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/myhostingaccount/public_html/mysite/myscriptdirectory/scriptname.php on line 111

    line 111 is:

    if (in_array($value->merchantID,$mymerchants)or $mymerchants[0]=="All"){


    any ideas?

    I assume the second argument is "$mymerchants" which is what was changed.
    Well, $mymerchants isn't an array, it's a string created by implode(). The in_array function requires an array. Seems like you need to use $merchant instead.

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

  25. #25
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    Snib beat me to it.


+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Deals Database is not updating for FTP
    By WalMartian in forum ShareASale - SAS
    Replies: 2
    Last Post: September 16th, 2009, 07:00 AM
  2. SAS FTP down?
    By beachcom in forum ShareASale - SAS
    Replies: 1
    Last Post: May 11th, 2009, 08:39 PM
  3. The SAS ftp site is down?
    By Mr. Sal in forum ShareASale - SAS
    Replies: 3
    Last Post: October 23rd, 2008, 10:40 PM
  4. Automated FTP of TheNerds.net Datafeed File?
    By Uncle Rico in forum ShareASale - SAS
    Replies: 1
    Last Post: July 22nd, 2008, 10:50 AM
  5. Replies: 0
    Last Post: June 25th, 2003, 09:12 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
  •