LinkShare Web Services Coupon Feed PHP Example

I was working on a PHP page to dynamically generate the links to coupons offered by my advertisers from LinkShare network. Suddenly, LinkShare has terminated my account without a reason. The page is useless now that I am no longer an affiliate.

I am listing my code here so that at least someone can benefit from my work. Note that you need to replace your_token and your_mid with the actual ones. If you omit the mid field, the request includes all your advertisers. Also, do not forget to add error handling to the code to prevent any unsightly errors.

<?php
$url = "http://feed.linksynergy.com/coupon?token=your_token&network=1&mid=your_mid";
$xml = simplexml_load_file($url);
#
echo '<ul>';
foreach ($xml->link as $link)
  {
    echo '<li>';
    echo '<a href="', $link->clickurl, '">';
    echo $link->offerdescription, '</a> ';
    echo ($link->offerenddate=="ongoing"?'':'exp: '.$link->offerenddate);
    echo '<br />';
    echo '</li>';
  }
echo '</ul>';

?>

Here is the sample output.


This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.


5 Comments

  1. I’m currently creating my own implementation and I’ve come across a major stumbling block if you’re going to send some high volume requests to the feed. You’re only allowed 50 calls per GMT day. Our data entry staff will blow through that quota in about 30 minutes. I mean, in testing I used up our quota within a few hours. The only possible solution might be to download the feed to a local XML file and access it locally. I guess I could set up the script to download and overwrite the file 45 times a day but a quota just seems like something I shouldn’t have to worry about does it? What are your thoughts? Am I just overlooking a simple solution? Any help would be appreciated.

    Thanks

    • I did not even know that there is a quota limit. If that is the case, you definitely want to save the results locally for processing. You do not have to update your local list frequently, probably once or twice daily should be sufficient.

  2. I figured it would be a lot harder than that! Thanks for such a simple and easy to use solution. Now that LinkShare has opened up the coupon feed this code will come in handy.

Leave a Reply