Data Feed Sites, A Complete Guide – Part 4

<<< Read Data Feed Sites – Part 3

The Complete Guide to Data Feed Sites marches on.  If you’ve followed me this far, thanks for reading!   You’re in for a nice treat in Part 4.   In this post I’m going to give you a custom script.  Great success!

CTRtard’s ShareASale Site Builder

Features

  • Build a complete data feed site from any ShareAsale data feed in minutes.
  • Posts remotely to your WordPress sites so you install it one time and build out sites from a central location.
  • Contains a simple Templating System that lets you edit a single file using basic HTML to get your posts to look just like you want them.
  • Ability to Drip Posts so your data feed site will get built out slowly over time.  This will help indexing and ranking by encouraging spiders to visit your site frequently as new posts (feed items) get added daily.
  • Ability to Preview a Feed in an easy to read format so you can judge feed content and quality.
  • Ability to Preview Categorization.  Easily see item counts for each category so you can quickly tell how well a feed is categorized.
  • Ability to Preview what your WordPress posts will look like.
  • Ability to Ignore specific Categories and Sub Categories.
  • Un-protected source code allows easy customization and ability to tie it in to other content generators you may have.
  • 100% Free!

Installation

You can put the script files on pretty much any hosting account. You can even run it from your local machine if you’ve got a PHP web server setup.  (BTW, if you want a super easy to use package for Windows, I recommend WampServer, it’s great!)

The script works by making remote posts to your WordPress blog using the XML-RPC capabilities built in to WordPress.  This means, unlike data feed “plugins” on the market, it does NOT have to be on the same machine/hosting account or be added to each WP site.   Time saver!

So ideally, you want to put the script in one place and use it from there for all your successive data feed sites building.

Setup Your WordPress Site

Login to your target site (the WordPress site that will be your data feed site) and under Settings > Writing, tick the Enable XML-RPC checkbox. If you haven’t already done so, now is the time to install the recommended data feed site plugins and configure them.

Adjust Script Setttings

The first thing you need to do is get a .csv file for the ShareASale data feed you want to use.  Download and unzip the file and upload it to the script directory.   Note the name of the file.  It should be [merchant_id].txt  (e.g. 12345.txt)

Next, open up the script file “shareasale.php” in your editor.  This is the main script. You’re going to need to adjust some settings.

Fill out the section “// WordPress Login Details” appropriately.   Regarding the $xmlrpc_url value, you should just adjust it for your domain name.  To make sure you’ve got it right, you can paste your URL in your browser for testing (e.g. “http://yourdomain.com/xmlrpc.php”) If your URL is correct and you’ve setup WordPress right, you should see the message “XML-RPC server accepts POST requests only.” appear in your browser.

Under “// Data Feed .csv File Details” section, change the value of $feed_file so it matches the filename of the csv you uploaded previously.   $your_user_id is your ShareASale user id.  You can see your ID at the top of the page when you log in to ShareASale.  The value of $template is the file used as a post template.  The default works fine, details on how to edit/change that are below.

Under “// Row Control”, you can limit which records in the data feed you want to use.  This is very useful when you are first just checking out a feed.  Some feeds are very large and having a way to just look at chunks of it will make your life easier.

$max_days_in_future allows you to configure how far into the future you want posts to be made.  The script uses WordPress’s post scheduling function to make this work.  So you run the script once when you build your site and your actual WordPress site will drip your posts according to the schedules that you’ve set.   Set and forget. Sweet!

Script Modes

The script has 4 modes.   All of these modes are affected by the “Row Control” settings mentioned above. So to limit the output or run through the whole data feed, you’ll need to adjust these settings.

Mode 0 CSV Preview Mode: Use this option to see exactly what the csv file contains.  This is useful to do first so you can see which fields you want to incorporate into your data feed site.

Mode 1 CSV Preview Mode – Show Categories Only: Use this option to see a complete list of categories in the .csv file.  This is useful in determining what type of categorization the data feed uses and how many records are in each category.

Mode 2 WordPress Post Preview Mode:
Use this option to see what your posts will look like.  This is useful in checking content formatting. Note: this just gives you a preview of the post title, body and basic formatting.  It is not able to show you the *exact* look of the post because the WP theme you have chosen will be applying styles.

Mode 3 WordPress Post Mode: Use this option to make actual posts.  Once you’ve checked your basic post formatting by using mode 2, you can use this option and the real posts will be made to your WordPress site.

Simple Template System

The file post-template.htm is the file you should edit to control how your posts look.  Open it in an html editor and you will see it’s just some basic html.  I chose to use tables, but if you’re one of “those people” who don’t like to use tables, knock yourself out and make your own file 😉

When you look over the html source, you’ll see tokens that will be replaced by the script.  For example, anywhere the token [[Link]] appears, will be replaced by your actual ShareAsale affiliate link.   The same goes for the other tokens.   You can use tokens as often as you like.

These tokens are named exactly according to each field in the .csv file.  The simple way to figure out what fields you want to use in your posts is to run the script in mode 0 (CSV Preview).  You will see something like this:

Every field in the left column will work as a token if you just wrap it with a [[ and ]].  I can’t make it any simpler than that!

A Short Walk-through

I typically use the modes in order.  I use mode 0 to decide if I even like the feed.  Then I use mode 1 to get a handle on how well it’s categorized. If categorization sucks, I move on.

Based on what I see in mode 0 and mode 1, I edit my template to my liking.  Every feed has different info, so taking the time to present the data in a useful way will definitely influence how well your site does.  Everything else is being automated, so don’t get lazy!  Take 10 minutes to format your posts.

Next, I run it in mode 2, so I can see the overall layout as it will appear in my posts.  If this looks good, I do 10 posts by setting $row_start = 0 and $row_count = 9 using mode 3.   I check the links on my blog, making sure everything looks good.

If everything checks out with my limited test posts, I let ‘er rip and set $row_count = 0 so the script will run through the entire feed.  Taking the time to make sure things look OK is worth it. Otherwise, you might have to delete hundreds or thousands of posts on your blog and that sucks!

Step Up Your Game

The people who will get the most out of this script will be the ones who put some effort into being different.   Re-read the previous posts in this series to refresh your memory, then go to town and mod the script.

Keep in mind, the biggest advantage to using my script is that you can customize the output.   There are plenty of slick data feed plugins on the market, but they are very hands off and customization is hard or impossible.  With this script, you are in control, so leverage that fact.

I’ve only scratched the surface here, and honestly this is one of those times you should just get your hands dirty.

Read through the source code.   I put some comments here and there that indicate good places to add your own stuff.  Ideally, you want to add some more content to each post.

Of particular note, is how to customize the post category.  Line 209 is where the post category is built. By default it uses merchantCategory and merchantSubcategory.  This may or may not work for your particular feed.  So that’s one thing for sure you want to play with.

Attention Coders

If you come up with some slick mods you want to share, shoot me an email or leave a comment. It would be cool to see this script improve with some more features.

Download

This script is 100% free, it won’t cost you a dime.   But I am reserving it as a thank you for joining my list. Joining  only takes a minute, just fill out the form at the top right of this page. After you verify your email, you’ll get the script download link in your inbox.  (If you’re already on my list, you should have the email already.)

Note: You have my word I’m NOT going to spam you weekly with crappy guru offers like most of the “super affiliate bloggers”.   Believe me, I hate that shit as much as you do!    In fact, chances are good you will rarely see an email from me unless I have something important to share.

Conclusion

This concludes the series: Data Feed Sites, A Complete Guide. I hope you guys enjoyed it.  If I missed anything or you have questions, please post them in the comments — that way everyone can benefit from the discussion.

Leave a comment

Leave a Reply to Nicole Cancel reply.

*

*

CommentLuv badge
Cancel reply

43 Comments

  • WOW! Awesome stuff, will definitely give it a go!

    Thank you so much for putting it together! 🙂

    • You’re welcome. Thanks for reading & commenting!

  • Awesome value in these posts! This is the good stuff! Thank you for putting it together. You know, you just made me realize I should have used the XML-RPC interface for a site I did using a datafeed plugin. Brilliant stuff.

    • Always glad to get some feedback from another coder. Glad you got something out of this Slave.

      Thanks for reading and commenting!

  • Awesome, I’m going to try it out, thanks for the script!

    • Your welcome Kang. Please post another comment and update us on how things go.

      Thanks for reading and commenting.

  • Alfred

    Another great post. Few questions:-
    1. How far do you think a data feed site can go?
    2. What is your best achievements so far for data feed site?

    I don’t have a shareasale account yet. It would be great if you can post your shareasale ref link here. I believe many people are willing to join under you. Send to my email if you don’t want to make it public.

    In between, your daily drip posts feature for your site builder looks cool.

    • Data feed sites are like everything else. It depends on how much effort you put into it. If you use the techniques I’ve outlined, you will get your site indexed and get free organic traffic. How much traffic and how much you make is totally dependent on your niche.

      Also, as I’ve mentioned before, you should try and add additional content. The script is easily customized and you *want* to customize it to avoid looking like everyone else. I’ve intentionally given you a bare bones script you can easily build on.

      Like I also said, the key here is to roll out a bunch of these. If you make a point of building a few a week, you’ll do well.

      And finally promotion and link building is a huge part of the puzzle. Effort here pays off with more traffic and more money.

      My shareasale.com referral link.

      Post back and let us know how you do. Thanks for reading and commenting!

  • Awesome script, I’m going to give it a go tonight and see what I come up with.

    • Glad you like it Clarke. Post a follow up comment and let us know how you do.

      Thanks for reading and commenting!

      • No problem you put out great content. I hope to have an old site I’ve got revamped using this in the next couple of days. I’ll stop back by and post it so you can see how it turned out.

  • Am I missing something or does this current script not have the option to create subcategories in WordPress?

    • You are missing something.

      Line 210 & 211

      $post_category = trim($merchantCategory) . ” – ” . trim($merchantSubcategory); // set the category for this post
      $post_categories = array( htmlentities($post_category) ); // add the category to the category array

      As you can see, the first line is creating a category based on “merchantCategory – merchantSubcategory”.

      If you want to adjust this, just change how the $post_category string is built. You can use any of the strings (fields) the script makes available to you from the data feed.

    • If you meant child categories (as in, Parent > Child Categories) then no, the current script doesn’t do that.

      That should be pretty easy to add though. But I don’t bother with them. I use a combination of Categories and Tags for most sites. You can build out the tag array easily, comments are in the script.

      • Thanks, I’ll take a look at that and see if I can add it in at some point. I’m just using parent categories at the moment.

        I ran the script on about 2900 products last night and it worked great, just took some time to fully run through.

  • Robert

    Any recommendation on a good wordpress template to use? I know there are a lot, but I’d rather not trail and error through a ton of them to find a decent one, if someone can recommend a good one for this purpose.

    • You’re right there are a bunch. It comes down to preference. For ecommerce, I would mimic the big boys. All of them have clean sites with lots of white space.

      Go to the WordPress.org theme archive and search for themes tagged with “clean”.3

  • Don

    Great script! Only thing lacking at this point it updating products to reflect price changes. If code could be written to overwrite posts when the script is run, that would be awesome :). I’d pay for that functionality.

    • Glad you like it Don. Adding something like that is totally possible, but to do it right you would want to keep track of each item you posted in a separate database. Doing something like this is a pretty substantial thing since it involves building out some infrastructure. Might cost a bit 😉

      But I like your thinking. Investing in your own backend system is a way to surpass your competitors who are either too dumb or too lazy to think of doing something like this.

  • Jimmy Harmon

    Signed up and confirmed my email. Just trying to find out where I can download the WP script.

    • You should have received an email right after confirming that has the script as an attachment.

  • joel

    Fantastic Script! I am using it now and it is working well.
    I would like to use tags. I know there is a section in the script where you can add them but I do not know how. In other words, do I integrate manually the tags in the csv file? Or do i enter them manually in the script? Or how do I define an array so that I can use several tags?

    I not totally proficient in coding but some orientation will help a lot!

    thanks. Great script!

    • Hey glad you like the script! I haven’t heard much feedback yet, so it’s good to hear it’s working for you.

      So to use tags, you need to modify line line 213. Currently it reads:

      $tags = NULL;

      If you take a look at the comments just below, on line 217, it gives you an example:

      $tags = array( htmlentities(trim( $SOME-STRING )), htmlentities(trim( $SOME-STRING )) );

      So let’s say, you want to tag each post with the ‘Custom1’ and ‘manufacturer’ column in the csv file. You would change line 213 to look like this:

      $tags = array( htmlentities(trim( $Custom1)), htmlentities(trim( $manufacturer)) );

      You can see a list of strings for each column near the top of the script. I hope this helps!

  • joel

    Yes, I got it. I have to do this in the csv file so that each row has its own tag, right?

    One more thing, I have now access to datafiles from commission junction. As you know its datafiles format is different from that of sharesae. Do you know of a not-so-complicated way to transform CJ format into SAS format?

    thanks again

    • “Yes, I got it. I have to do this in the csv file so that each row has its own tag, right?”

      No, you don’t get it. You do NOT have to change ANYTHING in the csv file. At the top of the script, the CSV file columns are “loaded” into strings for you. All of those strings are available to you (the script) and can be used anywhere you see fit. That means tags.

      So, the point is, you can create your tag(s) from ANY EXISTING ROW DATA. In the example above, I showed you how to create tags from Custom1 and manufacturer columns.

      Editing the CSV file rows *could* be done, but it’s kind of retarded to do so unless you have a good reason. It’s much smarter/more efficient to do this programatically, within the script. I hope that makes sense now 😉

      As for CJ, you would not want to conform CJ format to SAS format. Again, that would be silly. What you would do is simply make a copy of the script and modify it for the new format. It would not be hard at all but if you are brand new to PHP, it might be a little daunting

  • I accidentally jumped here looking for improvising my creations. I made it to load datafeeds from 5 networks, and anyone can find it useful if required to load cj,paidonresults,affiliatefuture,buyat along with shareasale datafeeds too.But I think yours has unique features that I have not implemented.
    For plugin details one can visit datafeedplug.in

  • Finally, I have website suitable for data feed site. But I can’t find the download link for your Shareasale site builder script. I have downloaded it before, but I think I have lost the files. Thanks

  • Found the script. Will let you know if my feed store works 🙂

  • usef

    hi,
    first of all thanqe you for this plugin,
    but i got somme problems, i got a fill with 2GO of content i want to postet it but it give me this error ” Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 491530952 bytes) in C:\Program Files\EasyPHP-5.3.6.1\www\sasscript\shareasale.php on line 72 ” pleas will you help me
    and pleas how can i stop comment.

    • This error happens when you try to process a very large feed. PHP is running out of memory at 128MB. You can try adding this to the top of the script, just below the first line that reads <?php

      ini_set('memory_limit','256M');

      If the error continues, ask your hosting support about how you can increase PHP's memory.

      Thanks for reading!

  • usef

    hi , i wana add this code ino post template : so i give the keywords and show me the resultat how can i do it
    code:

    = $n) {
    return;
    }
    if ($tagName == “ITEM”) {
    printf(“”);
    printf(““);
    printf(““);
    printf(htmlspecialchars(trim($title)));
    printf(“
    “);
    printf(“
    \n”);
    printf(“”);
    if (strlen ($description) > 0) {
    printf(trim($description));
    }
    printf(“\n”);
    printf(“\n”);
    printf(“”);
    $title = “”;
    $description = “”;
    $link = “”;
    $iurl = “”;
    $insideitem = false;
    $i += 1;
    }
    }
    function characterData($parser, $data) {
    global $insideitem, $tag, $title, $description, $link, $iurl;
    if ($insideitem) {
    switch ($tag) {
    case “TITLE”:
    $title .= $data;
    break;
    case “DESCRIPTION”:
    $description .= $data;
    break;
    case “LINK”:
    $link .= $data;
    break;
    case “URL”:
    $iurl .= $data;
    break;
    }
    }
    }
    function parse_feed ($url, $num) {
    global $insideitem, $tag, $title, $description, $link, $iurl, $i, $n;

    $insideitem = false;
    $tag = “”;
    $title = “”;
    $description = “”;
    $link = “”;
    $iurl = “”;
    $i = 0;
    $n = $num;

    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, “startElement”, “endElement”);
    xml_set_character_data_handler($xml_parser, “characterData”);
    $fp = fopen($url,”r”)
    or die(“Error reading RSS data.”);
    while ($data = fread($fp, 4096)) {
    xml_parse($xml_parser, $data, feof($fp))
    or die(sprintf(“XML error: %s at line %d”,
    xml_error_string(xml_get_error_code($xml_parser)),
    xml_get_current_line_number($xml_parser)));
    }
    fclose($fp);
    xml_parser_free($xml_parser);
    $i = 0;
    }
    $rssfeedurl = ‘http://blogsearch.google.com/blogsearch_feeds?hl=en&q=&ie=utf-8&num=10&output=atom
    ‘;

    $rssfeedurl = str_replace(“-“, “%20”, “$rssfeedurl”);

    parse_feed (“$rssfeedurl”,4);
    ?>

    • In the script, I put comments where you can add your own code. That’s the place where you can add extra info (like keywords) to the post output.

      That being said, integrating this code properly isn’t something I can tell you how to do in a simple blog comment. If you can’t do this yourself, I suggest you hire a programmer either from an outsourcing site, or check out my page on Custom Programming here.

  • bellir

    Curious about the script.

  • I had downloaded your script and follow the instructions here step by step. but, when I open the post-template.htm it’s not generate the data from the feed I’d uploaded. It’s different from the screnshot you made here. Just a simple table with blank parameters (the mercant ID, link, image, etc doesn’t appear) Am I make a mistake? Please help

  • Thanks before

  • This was an awsome set of posts, but the build up on this page was a let down because I dont see a download link for the script (unless im blind)
    Mark’s latest blog post: Write a Post & Get a Burger and T-shirt!

    • The post mentions you get the script after opting in to my mailing list.

      • Imral

        I don’t see a link or form to join your mailing list at the location you said (top right).

  • Dirk

    Thanks for this great script!
    I have installed this script on my server and have run the script in Mode 0, 1 & 2 without any problems. When running the script in Mode 3 I get the following errors –
    “ERROR! Something went wrong – -32700 : parse error. not well formed”.
    I have tried this on 3 different wordpress instals with the same results. The last site I tested this on was a fresh instal of WordPress, and I even deactivated all of the plugins I had installed, and still getting the same error!
    Am I missing something?! Thanks, in advance, for your help!

    • Hmm, I don’t really have time to test this for you. Sorry. By best guess is something is messing up with the data being send to WP’s XMLRPC engine. I’d suggest checking your login info.

  • Nicole

    Hello

    I would really love to receive this script as I am looking for a way to use shareasale data feeds for days (i want each products on its own post). I cannot see any opt in form, so what must I do in order to receive it? Thanks so much

  • Scott

    Great blog, and great data feed series.

    Any chance of opting in to get the script? Or have you gone on to bigger and better things?

    Thanks,
    Scott

    • Sorry I removed my optin-form when I changed the blog theme. I’ll work on getting that back up.

 
 
 

Related posts by category

Related posts by tag