Money-Code

Coding For Online Success

Dynamic XML/RSS Feed using PopShops

| 1 Comment

Well, I noticed that I haven’t added any code examples in a while, so here is a new one I’m working on now. PopShops is a great tool to display products from different merchant networks like Commission Junction, LinkShare, ShareASale, etc. You can quickly create product pages and have them delivered using multiple methods. Methods include javascript, PHP, XML, etc.

I’ve been using the Pro account for a while on a single site. With my continuing efforts to become more diversified I’ve been focusing on more PopShop stores, so I upgraded my account to the Enterprise level. This is important if you want to have unlimited affiliate PIDs, etc. Currently the free or Pro option allows for one affiliate ID / merchant. So if you have many domains listed with CJ, you can only provide one PID to track. That’s a problem, and was an obvious choice to upgrade the account. If you upgrade you also get additional features like XML/RSS options for your store.

With this option you can easily create dynamic XML/RSS feeds. The example below is using XML, since I wanted price and image URLs to be parsed out of the content. RSS includes these directly in the ‘description’ and would require additional, non-needed parsing. My example is also using PHP5’s simplexml_load_string() function. You will need to make sure that PHP is compiled with simplexml support for this to work. If you’re using PHP4 you’ll most likely have to use domxml_open_mem() for this to work. I will not cover/support PHP4 in this post.

You will need to follow these instructions listed at PopShops (http://www.popshops.com/faq/affiliate-rss-xml)

What you will need:
1. A enterprise account

How you do it:
1. Go ahead and create your shop the normal way by searching and adding products.
2. Go to the ‘Pop it in’ tab.
3. Select the ‘RSS2’ or the ‘XML’ option in the code drop down.
4. Copy the link to the rss version of your shop, and paste it into the address bar of your favorite browser (FireFox). It should look something like this:
http://shops.popshops.com/shops/c49…59d6dc61a73.rss
5. You should see an RSS/XML version of your shop.
6. Now just add ?psps_search=KEYWORDS obviously replacing KEYWORDS with whatever term you are searching on. You will now have a keyword driven RSS/XML feed. So for example:
http://shops.popshops.com/shops/c49…earch=ipod+case

<?php
function send_request($rest){
        global $rootpath;
        $ch                     = curl_init();
        $timeout                = 5; // set to zero for no timeout
        curl_setopt ($ch, CURLOPT_URL, $rest);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $file_contents  = @curl_exec($ch);
        curl_close($ch);
        return $file_contents;
}

$count                                  = false;
$url                                    = ‘http://shops.popshops.com/shops/0snmheiasfasdeadsff_search=star+wars’;
$rss_feed                               = send_request($url);
if(strlen(trim($rss_feed)) > 0){
        $resp                           = simplexml_load_string($rss_feed);
        foreach($resp->product as $item) {
                $count                  = true;
                echo $item->name."
"
;
                echo $item->price."
"
;
                echo $item->description."
"
;
                echo $item->url."
"
;
                echo $item->large_image_url."
"
;
                echo "

";
        }
}
if(!$count){
        echo ‘no records found’;
}
?>
 

One Comment

  1. Great info! I’ve been looking for info on feeds for PopShops and also noticed info for paging eBay feeds! I’ll be coming back for more info. Thanks…

Leave a Reply

Required fields are marked *.


CommentLuv badge