Home     Articles & Projects     Products & Web Services     Forum

Shopping.com API

Hi David,

I want to create a site that uses Shopping.com API is magic parser helpfull for this type of site ??

Robert

Hi Robert, It will almost

Hi Robert,

It will almost certainly be helpful. Bear with me and tomorrow i'll try to pull together various examples that I've worked on before and we'll work through it....

Cheers,
David.

Hi David! Thanks alot david

Hi David!

Thanks alot david looking forward to hear from you tomorrow.

Robert,

Hi Robert, I thought i'd

Hi Robert,

I thought i'd done some shopping.com API PHP code before - here's an example that might help kick us off:

<?php
 
require("MagicParser.php");
  print
"<h1>shopping.com API Test</h1>";
  print
"<form method='GET'>";
  print
"<input type='text' name='q' value='".htmlentities($_GET["q"])."' /> ";
  print
"<input type='submit' value='Search' />";
  print
"</form>";
  function
myRecordHandler($item)
  {
    print
"<h3><a href='".$item["URL"]."'>".$item["TITLE"]."</a></h3>";
    print
"<img src='".$item["PRODUCT-IMAGES/IMAGE"]."' />";
    print
"<br /><br />";
  }
  if (
$_GET["q"])
  {
   
$url  = "http://demo.au.api.shopping.com/scripts/GSIsapiExt.dll/";
   
$url .= "linkin_id-YOUR-ID/";
   
$url .= "keyword-";
   
$url .= "".urlencode($_GET["q"]);
   
MagicParser_parse($url,"myRecordHandler","xml|DSP/RESULT/DOMAIN/DOMAIN-LISTING/");
  }
?>

This is based on some code I worked on with another user, where YOUR-ID is a 7 digit number, presumably your shopping.com affiliate ID or an API key.

Secondly, i'm not sure if "demo.au" implies that this is an interface to an Australian instance of the database (and presumably a demo one at that) - so this probably needs to be changed....

If you don't have a suitable ID, or not sure what to change the URL to (in place of demo.au) let me know and we'll take it from there!

Cheers,
David.

Hi David! I have tested this

Hi David!

I have tested this solution on my server but it doesnt seem to work even though when I try entering this http://api.shopping.com/scripts/GSIsapiExt.dll/linkin_id-*******/keyword... url on my web browser I do get results,

thanks
Robert

Hi Robert, Did you change

Hi Robert,

Did you change the relevant sections of the code to match the URL you're typing in directly. It looks like it should be something like this:

<?php
 
require("MagicParser.php");
  print
"<h1>shopping.com API Test</h1>";
  print
"<form method='GET'>";
  print
"<input type='text' name='q' value='".htmlentities($_GET["q"])."' /> ";
  print
"<input type='submit' value='Search' />";
  print
"</form>";
  function
myRecordHandler($item)
  {
    print
"<h3><a href='".$item["URL"]."'>".$item["TITLE"]."</a></h3>";
    print
"<img src='".$item["PRODUCT-IMAGES/IMAGE"]."' />";
    print
"<br /><br />";
  }
  if (
$_GET["q"])
  {
   
$url  = "http://api.shopping.com/scripts/GSIsapiExt.dll/";
   
$url .= "linkin_id-*******/";
   
$url .= "keyword-";
   
$url .= "".urlencode($_GET["q"]);
   
MagicParser_parse($url,"myRecordHandler","xml|DSP/RESULT/DOMAIN/DOMAIN-LISTING/");
  }
?>

Now, if that doesn't work it implies that the XML response is not in the same format as the earlier demo I wrote. Therefore, could you perhaps save the XML and email it to me to take a look at? (reply to your forum reg email)

Cheers,
David.

Hi David, Whats your email

Hi David,

Whats your email

Robert

Hi Robert, If you reply to

Hi Robert,

If you reply to your davidmorison.com forum registration email that will get to me...

Cheers,
David.

Hi David, You saying if I

Hi David,

You saying if I reply to {email saved} ?

Robert

Hmmm, sorry - perhaps the

Hmmm, sorry - perhaps the addressing isn't setup properly - i'll look into that!

Send it to support@iaaisoftware.com

Cheers,
David.

Hi Robert, Thanks for the

Hi Robert,

Thanks for the file. It is actually returning a slightly different format. In your code, change the line:

MagicParser_parse($url,"myRecordHandler","xml|DSP/RESULT/DOMAIN/DOMAIN-LISTING/");

to:

MagicParser_parse($url,"myRecordHandler","xml|DSP/RESULT/DOMAIN/DOMAIN-LISTING/HYBRID-ITEMS/PRODUCT/");

Now i'm not sure if this will work for all queries (I think some may be returning more than one DOMAIN-LISTING record instead of multiple PRODUCT records), but worth trying to get this working first as it will prove that you are able to open URLs remotely via PHP etc...

Cheers,
David.

Hi David, I have tested it

Hi David,

I have tested it and it works fine thanks. However the only problem is the links are pointing to shopping.com instead of the sites which are offering the products ?
I have put the test page over here http://citishoppingguide.co.uk/test.php?q=laptops
what I want is to create a site like theselection.co.uk and be able to hide my link id

Thanks,

Robert

Hi Robert, Are you basically

Hi Robert,

Are you basically looking to develop something along the lines of Price Tapestry's jump.php (although not necessarily with the click tracking)?

Hi David, Yes if that is

Hi David,

Yes if that is posible

I have a script that I bought from this site http://www.affiliatescript.co.uk/demo/shopping/ but their script doesnt hide the link id , its abit too slow and its not url friendly like PT

thnaks

Robert

Hi Robert, Sure - I can work

Hi Robert,

Sure - I can work through that with you tomorrow.... Do you have phpMyAdmin installed on your server so that you can create / manage databases without having to write admin scripts?

Hi David, Yes Thanks Robert

Hi David,

Yes

Thanks

Robert

Hi Robert, I'm going to make

Hi Robert,

I'm going to make this into a generic (links from API > database > jump script) project which i'll work on today and write-up as a separate article (then users can comment in the article). Check back late afternoon for something....!

This will be useful for all sorts of API projects.

Cheers,
David.

Hi Robert, I've written up a

Hi Robert,

I've written up a project to do this - let me know how you get on! (you should be able to comment on the blog entry itself)....

http://www.davidmorison.com/node/18

To incorporate this into the above code; here's what the record handler function might look like when combined with the jump library:

  function myRecordHandler($item)
  {
    print "<h3><a href='jump.php?id=".jumplib_getID($item["URL"])."'>".$item["TITLE"]."</a></h3>";
    print "<img src='".$item["PRODUCT-IMAGES/IMAGE"]."' />";
    print "<br /><br />";
  }

Don't forget to require("jumplib.php"); at the top of your script...!

Cheers!
David.

Hi David, Its working fine

Hi David,

Its working fine shopping.com search results returns five types of results 1, 2, 3, 5 results type 5 has the results that I was looking for {link saved}

Thanks,

Robert

Hi David! Am a bit stuck on

Hi David!

Am a bit stuck on how to manupulate an xml type file generated by the shopping.com API using Magic Parser

Thanks

Robert

Hi Robert, It probably

Hi Robert,

It probably involves using the loop whilst appending @n trick....! Can you post an example of the result you are trying to parse and i'll take a look... (use the <code> tags to post the XML)

Cheers,
David.

Hi David! I wanted to ask

Hi David!

I wanted to ask how can I prevent a sybol like ? from appearing instead of £ ?

for example when I get results like this Below £10 form the API the output shows like this Below ?10

thanks

Robert

Hello Robert, That's a

Hello Robert,

That's a character encoding issue - the character set of the data in the feed (looks like UTF-8) is not the same as the character set that web browsers are interpreting your web page as.

You can force this with the following PHP at the very top of your script; it must come BEFORE any output has been created, otherwise PHP cannot send the HTTP header...

<?php
  header
("Content-Type: text/html;charset=utf-8");
?>

Cheers!
David.

Hi David! It still doesnt

Hi David!

It still doesnt work

Robert

Hi, Other possibility is

Hi,

Other possibility is that it is iso-8859-1 - try this:

<?php
  header
("Content-Type: text/html;charset=iso-8859-1");
?>

Cheers,
David.

Hi David! That one worked

Hi David!

That one worked fine

Thanks

Robert

Hi David, This synbol ™

Hi David,

This synbol ™ doesnt work though is there a way round this one ?

Thanks

Robert

Hi Robert, What does it

Hi Robert,

What does it appear as?

Can you make it appear property by adjusting the character set manually in your browser (View > Character Encoding). Try selecting a few different ones (in particular utf-8 and iso-8859-1) and see what happens....

Hi David, Given a string

Hi David,

Given a string Like http://www.citishoppingguide.co.uk/merchant/PC-World/

How can I remve "http://www.citishoppingguide.co.uk/merchant/" this part of the string and remain with this one "PC-World/"

Thanks,

Robert

Hi Robert, If you always

Hi Robert,

If you always know what the string is going to be, just use str_replace, for example:

<?php
  $mystring
= str_replace("http://www.citishoppingguide.co.uk/merchant/","",$mystring);
?>

Cheers!
David.

Hi David, That worked

Hi David,

That worked perfect

Thanks

Robert

Hi David, Is PT and Magic

Hi David,

Is PT and Magic parser compartible with PHP5 ?

Thanks,

Robert

Hi Robert, Yes - both work

Hi Robert,

Yes - both work fine on PHP5!

Cheers,
David.

Hi David, Do you know how I

Hi David,

Do you know how I could solve this error message
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server

Thanks

Robert

Hi David, Ignore my

Hi David,

Ignore my previous message my ISP had dissable outbound links on the server

Thanks,

Robert

Hi David, Is there a way to

Hi David,

Is there a way to find out if this function MagicParser_parse(); is generating any error messages ???

Thanks,

Robert

Hi David, Here is the site I

Hi David,

Here is the site I have been working on Shopping

Robert