/LinkShare Web Services Coupon Feed PHP Example

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.