Simple example of Shopping.com API for Drupal

This is a simple example of how to use the Shopping.com API on a Drupal page. There is a more and better version coming [link]. But if you can't wait, here you go! I put this on an PHP enabled page: http://www.churchofeee.com/product_search, rather than spring for .NET product that costs $250 (why-- I couldn't use it on a PHP site, and why not spend the time DIY coding it)?


<form action="product_search">
<input type="text" name="search" value="<? echo htmlentities($_GET['search']); ?>"/>
<input type="submit" value="Search"/>
</form>
<?
$search_items = urlencode($_GET['search']);
// $search_items = 'eee';
$items = simplexml_load_file('http://api.shopping.com/dsp/linkin_id-8005272/keyword-'.$search_items);

if (($items) && (strlen($search_items) > 1)) {
print "<pre>\n";
foreach ($items->result->domain->{domain-listing} as $item) {
print l($item->title, $item->url)."<br/>";
}
print '</pre>';
}
else {
?>
Search for products-- computers, eee pcs, sub-notebooks, and all that great stuff!
<?
}
?>

Comments