Linkshare Web Services

Linkshare Web Services

Building a product site using the LinkShare Merchandiser Web Service is one of the easiest and most straight-forward tasks you can do. If you’re just getting started with datafeeds and product-based sites, you may want to start here.

If you don’t have an account, you first need to signup with LinkShare. Then login, and click on Web Services under Links. Next, generate or update your token. You’ll need this when making requests.

When I first generated my token, the services were not working for me. After contacting support (which was easy to do), they promptly replied:

Please be note that the feed token MAY take up to 24 hours to fully activate from the time it was initially generated/reset.

Linkshare Web Services Token

Linkshare Web Services Token

However, 30 minutes after being generated, the token was active.

Building the query URL is fairly straight-forward. At its simplest, you pass your token and a keyword:[your token here]&keyword=backpack

Refer to the Merchandiser Query API page for documentation on the other parameters you may use, such as category, merchant, and sorting.

Putting it all together:

$cURL = '[your token here]&keyword=backpack';
$xml = simplexml_load_file($cURL);

for ($i = 0; $i < count($xml->item); $i++) {
	$oProduct = $xml->item[$i];
	<div class="post">
		<h2 class="title"><a href="<?= $oProduct->linkurl ?>" target="_blank" style="text-decoration:none"><?= $oProduct->productname ?></a></h2>
		<div class="entry">
			<p><a href="<?= $oProduct->linkurl ?>" target="_blank"><img src="<?= $oProduct->imageurl ?>" alt="<?= $oProduct->productname ?>" title="<?= $oProduct->productname ?>" style="max-height:100px; max-width:100px; float:left" onerror="ImgError(this)" /></a><?= $oProduct->description->short ?></p>
			<br style="clear:all" />
		<div class="meta">
			<p class="byline"><a href="<?= $oProduct->linkurl ?>">$<?= number_format($oProduct->price, 2) ?></a></p>
			<p class="links"><a href="<?= $oProduct->linkurl ?>" class="more">Get More Info</a> <b>|</b> From <a href="<?= $oProduct->linkurl ?>" class="comments"><?= $oProduct->merchantname ?></a></p>

Refer to the 3rd step in my Building a Datafeed Site series for an explanation of the ImgError JavaScript event.

This PHP code is meant to be dropped into a static WordPress template, many of which can be downloaded from free CSS templates.

If you wanted to improve performance, you could save the Merchandiser results to MySQL for local caching.

To see a site built on the LinkShare Merchandiser API, check out this site on Transcend SD Cards.

May 11, 2011 Update
LinkShare has updated the URLs for their APIs. The code here has been reflected with the new URLs.

21 Comments » for Using the LinkShare Merchandiser Web Service
  1. Garrett says:

    Nice write-up. As always, the code samples are a huge help for wrapping your mind around how feeds function. FYI, I’m currently seeing feed errors on your SD site (not sure if it’s your side or LS).


    • Eric Nagel says:

      Hahaha – of course, the service is down now πŸ™‚

      Maybe my next post should be about using memcache to cache results for when the provider’s API goes down πŸ™‚

      • Garrett says:

        I’d by interested in that one…seems like hitting APIs in realtime (in my limited experience) is a quick/easy way to get rolling, but probably not a great long-term solution if your site gets good traction.

  2. Sarita says:

    Hi I am facing the following error on running the file:

    Warning: simplexml_load_file() [function.simplexml-load-file]: parser error : Extra content at the end of the document in /home/myprojec/public_html/development/projecttest/cashverseur/API/linkshare/index.php on line 50

    Warning: simplexml_load_file() [function.simplexml-load-file]: Warning: simplexml_load_file() [f in /home/myprojec/public_html/development/projecttest/cashverseur/API/linkshare/index.php on line 50

    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/myprojec/public_html/development/projecttest/cashverseur/API/linkshare/index.php on line 50
    There are no available products at this time.

    I have put the url=””

    $token = “594978f1ee8529987d5d516816e57358fa79ca6c3206108fdfada906a9eac5e2”;

    Please share the code if there is some php support error.I am runnig PHP 5.2.1 on my server.


  3. Sarita says:

    No, I am not.I just want to get all products not any specific but i started with this value.Could you please help me how to get all products?I have only account and also don’t have much information about this.But i just want to get all products without any criteria.
    Many thanks!

  4. Sarita says:

    Can’t i get any product feed if I’m not approved by any merchant program?

  5. Sarita says:

    Thanks for the reply Eric.

  6. Sarita says:

    Thanks Eric.Finally i got products.Can you help me with clickbank API to get products?

  7. Ritesh says:

    i am new in feed api development.
    i have one problem in linkedshare product full merchandiser file in php how to i can auto download file from my ftp.
    i use ft_get but its only download 10 file.

    than i have one more query how to easy way to in parse this .xml.gz file to table please guide me.


    • Eric Nagel says:


      I seem to recall something goofy about how Linkshare handles FTP files. Like the files don’t actually exist, but if you request them, it’ll magically appear and be sent to you? It’s unrelated to the API, so I don’t know much more about it.

      Use the API to determine your merchant relationships, then request the file (even if it’s not there) and you may get it.

  8. david E says:

    would you know how to query the linkshare Merchandiser Query tool by isbn. I cant find information on that anywhere

  9. Muhammad Junaid says:


    Please can you help me to get Sales from the Linkshare? I could not find any sufficient data about the API. Thanks in advance.

  10. rajp says:

    My code works perfect on my local machine but fails on the hosting site.Did you overcome anything like this issue with it something to do with the simplexml_load_file is not enabled on hosting

2 Pings/Trackbacks for "Using the LinkShare Merchandiser Web Service"
  1. […] To help you get started here’s a great blog post on the topic by Eric Nagel. […]

Leave a Reply

Your email address will not be published. Required fields are marked *