Skip to content


Roverize eBay links on the fly

I figured I should work on another code example since it’s been a while! On one of my sites I needed to convert URLs to be active anchor links. Along with being active anchor links, I thought it would be cool to convert eBay URLs to automatically contain the rover code. Now, all I need to do is paste a straight eBay link to a listing and it will automatically be set to go.

I do this with two custom functions convertEbay() and change_string(). change_string() has a very powerful function called preg_replace_callback() which detects if there is a URL and passes it to the convertEbay() using the callback argument. I store my rover portion as a PHP constant.

<?php
function convertEbay($inLink){
        $encodeLink                     = urlencode($inLink[0]);
        $out                            = eregi_replace("(.*cgi.ebay.com.*|.*cgi.ebay.co.uk.*)",ROVER.$encodeLink,$inLink[0]);
        $out                            = "<a href=\"".rtrim($out,‘.’)."\" target=\"_blank\">".$inLink[0]."</a>";
        return $out;
}

function change_string($str){
        $str    = trim($str);
        $str    = preg_replace_callback(
                                        "/(((f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%\|_\+.~#?&\/\/=]+)/",
                                        "convertEbay",
                                        $str
                                );
        return $str;
}
?>
 

Incoming search terms:

  • roverize links


Related posts:

  1. Dynamically create eBay widgets from existing rover code
  2. Tracking converting keywords from your PPC campaigns
  3. EPN Newsletter – Referring URL Visibilty
  4. Pay Attention to your Roll-Your-Own EPN sites
  5. Paging eBay RSS results

Posted in EPN, Programming.

Tagged with , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

CommentLuv badge