Support forum login

©2006-2012 IAAI Software

Contact Us Privacy Policy

Web Services and API Calls

Submitted by hutchinsonm on Thu, 2010-07-15 23:00.

David,

I was just curious if the PT script is capable of handling RSS Feeds from merchants and if there is a way to make Web API calls.

Thanks

Matt

Submitted by support on Fri, 2010-07-16 07:58.

Hello Matt,

Sure - it's reasonably straight forward to make an API module by using, for example, ebay.php as a template (amazon.php is slightly more complex as it contains the URL signing code).

The Magic Parser Format String for processing an RSS response would be xml|RSS/CHANNEL/ITEM/, and then changes required of course to the record handler to display the fields typically found within an RSS ITEM. Here's a template to get you started:

<?php
  
require_once("includes/MagicParser.php");
  function 
myRSSRecordHandler($item)
  {
    global 
$config_currencyHTML;
    print 
"<tr>";
    print 
"<td>";
    
// insert image HTML here if available
    
print "</td>";
    print 
"<td width='50'>&nbsp;</td>";
    print 
"<td valign='middle'>";
    print 
"<h4><a href='".$item["LINK"]."'>".$item["TITLE"]."</a></h4>";
    print 
"<p>".$item["DESCRIPTION"]."</p>";
    print 
"</td>";
    print 
"<td width='50'>&nbsp;</td>";
    print 
"<td valign='middle' align='center'>";
    
// insert price HTML here if available, you can prefix with $config_currencyHTML
    
print "<nobr><a href='".$item["LINK"]."'>More Information</a></nobr>";
    print 
"</td>";
    print 
"</tr>";
  }
  
// $q is set by both search.php and products.php
  
if ($q)
  {
    
$url  "http://www.example.com/api.asp?keywords=".urlencode($q);
    
// start the table
    
print "<div class='searchresults'>";
    print 
"<table width='100%'>";
    
// fetch the response and parse the results
    
MagicParser_parse($url,"myRSSRecordHandler","xml|RSS/CHANNEL/ITEM/");
    
// end the table
    
print "</table>";
    print 
"</div>";
  }
?>

Cheers,
David.

Submitted by hutchinsonm on Fri, 2010-07-16 15:36.

David,

I just want to be clear about my understanding on this. I can use the above example for RSS and API calls. Is that correct?

Thanks

Matt

Submitted by support on Fri, 2010-07-16 15:50.

Hi Matt,

The above is a very generic API example, whereby you have a URL that you can request that returns an RSS feed of results relevant to the query.

If you're not sure, if you can let me know the API request URL details (email if sensitive details area required) i'll take a look and work out the API code required based on the above.

One thing to bear in mind however, is to be careful when calling multiple APIs on a single page. It is thought that page load speed is becoming an important factor in rankings, so including multiple API calls on a single page where the interaction is all going on at your server rather than on the client is going to be impacting on page load significantly... something to bear in mind!

Cheers,
David.