Support forum login

©2006-2012 IAAI Software

Contact Us Privacy Policy

eBay API

Submitted by support on Mon, 2009-09-28 10:37.

Hi everyone,

Here is a basic eBay API script to enable you to compliment Price Tapestry generated search results or product pages with live content from eBay. To use this script, you will need to be a member of the eBay Developers Program, and in order to earn money from referrals you will also need to be a member of the eBay Partner Network or 3rd party affiliate network operating an eBay program as per the list that can be found on this page.

Download and Installation

Click here to download, and unzip ebay.php to your local computer. Open the file and edit the following lines at the top of the script as described below;

  $ebayAppId = "YOUR_APP_ID";
  $ebayGlobalId = "";
  $ebayNetworkId = "";
  $ebayTrackingId = "";

  • $ebayAppId
  • After logging in to the eBay Developers Program, access this page and copy your AppID parameter from the Production Keys section.

  • $ebayGlobalId
  • Can be left empty for ebay.com (USA site), otherwise enter the Global ID for the eBay locale you wish to link to from the list on this page; for example EBAY-GB for ebay.co.uk

  • $ebayNetworkId
  • ID of the affiliate network through which you are a member of the eBay affiliate programme. The full list can be found on this page; for example 9 for eBay's own Partner Network.

  • $ebayTrackingId
  • Your affilaite ID associated with the eBay affiliate programme specified in $ebayNetworkId. For the eBay Partner Network, this is your 10-character Campaign ID.

To install, simply upload the modified ebay.php to your main Price Tapestry installation folder (probably the top level folder of your site unless you have installed Price Tapestry into a sub-directory).

Usage

eBay results can be added to both search.php and products.php. In both files, to include eBay results at the end of the page, look for the the following code towards the end of the script:

  require("html/footer.php");

...and REPLACE this with:

  require("ebay.php");
  require("html/footer.php");

eBay results will then be shown (if available) using the $q parameter from the page; which are the search keywords if via search.php; or the product name if via products.php.

Submitted by alecs on Tue, 2009-09-29 13:53.

hi david..

Submitted by support on Tue, 2009-09-29 14:01.

Hi Alecs,

In most scenarios MagicParser.php will not have already been included; but in this case; simply comment out or delete line 7 of ebay.php:

  require("includes/MagicParser.php");

...and it should then run without error...

Cheers,
David.

Submitted by alecs on Tue, 2009-09-29 15:55.

hi david,

ok ... the amazon.php works now on the searchresults but gives me at the products this error

Fatal error: Call to undefined function MagicParser_parse() in /home/www/doc/6125/jojogo.com/www/amazon.php on line 137

the ebay.php doesnt gives me any result

thanks
alecs

Submitted by support on Tue, 2009-09-29 16:01.

Hi Alecs,

Best thing to do, is to re-instate the require() statement in both amazon.php and ebay.php but change the line to:

  require_once("includes/MagicParser.php");

That will make sure that whichever order (or even if individually) the API scripts are included they will include MagicParser.php if required...

Cheers,
David.

Submitted by jim on Mon, 2009-11-09 02:56.

Is there any way to limit the search results returned, so it only shows items from an eBay UK category ID ?

Submitted by support on Mon, 2009-11-09 09:31.

Hi Jim,

Did you set the UK locale at the top of your ebay.php file; it should be:

  $ebayGlobalId = "EBAY-GB";

Cheers,
David.

Submitted by jim on Mon, 2009-11-09 12:02.

yes - sorry I probably didn't make myself clear.... I meant how do I narrow my search down to a specific category (within the eBay.co.uk programme) .. like the category for football shirts, or concert tickets. The category number for the latter is catId=170272

Submitted by support on Mon, 2009-11-09 12:19.

Hi Jim,

Look straight forward enough - the operation name needs changing to findItemsAdvanced and then the category ID added to the request URL. To do this, in your ebay.php, look for the following code on line 33:

$url = "http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords";

...and REPLACE this with

$url = "http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced";

Then look for the following code on line 47:

$url .= "&keywords=".urlencode($q);

...and REPLACE this with:

$url .= "&keywords=".urlencode($q);
$url .= "&categoryId=170272";

Hope this helps!

Cheers,
David.

Submitted by jim on Mon, 2009-11-09 12:57.

For some reason, the eBay listings won't display at all if I make those 2 changes

I can get the original ebay.php script posted above to work fine (but obviously it searches the whole eBay.co.uk site, rather than just the specific category I want)

I tried substituting categoryId for catId in case that was a typo in your code, but neither worked as hoped. Any ideas why it doesn't display?

Submitted by support on Mon, 2009-11-09 13:03.

Hi Jim,

Sorry - one more change required. Look for the following code on line 54:

MagicParser_parse($url,"myEbayRecordHandler","xml|FINDITEMSBYKEYWORDSRESPONSE/SEARCHRESULT/ITEM/");

...and REPLACE this with:

MagicParser_parse($url,"myEbayRecordHandler","xml|FINDITEMSADVANCEDRESPONSE/SEARCHRESULT/ITEM/");

(the Format String for parsing the response has to match the call, that's all it was)

Cheers,
David.

Submitted by jim on Mon, 2009-11-09 13:09.

Thanks David.

Submitted by GemViper on Wed, 2010-04-28 06:13.

I Installed this on the latest version of PT, works flawlessly.

A tip, implement it just above the pagination/navigation code in search.php for a more seamless appearance and don't forget to add a line of text above it letting visitors know that they will end up on ebay if they click (as per EPN TOS).

A request, instead of using the eBay API the call for information can be made to the RSS version instead. Can we get a version made with the rss on the "to-do" list?

Keep up the great work.

Submitted by support on Wed, 2010-04-28 08:21.

Hi,

Thanks for your comments - i'll take a look at an RSS version...

Cheers,
David.

Submitted by babyuniverse on Thu, 2010-04-29 11:11.

Hi David,

I am using the ebay.php in my search results blended in to look like the price tapestry results.
I currently use $url .= "&keywords=".urlencode($q); in the ebay script.

Is there a way to add my own keyword on the end of this script.
I am creating a sunglasses site and the user searches for versace and PT returns only vercase sunglasses beacuse I have filtered the feed during import, the ebay results however show a mix of sunglasses and versace clothing etc. I would like the ebay script to add the word sunglasses to the end of the keyword.

Hope this makes sense
Richard

Submitted by support on Thu, 2010-04-29 11:17.

Hi Richard,

No problem - on line 47 of ebay.php you'll find:

    $url .= "&keywords=".urlencode($q);

Simply REPLACE that with:

    $url .= "&keywords=".urlencode($q)." sunglasses";

Cheers,
David.

Submitted by babyuniverse on Fri, 2010-04-30 11:41.

Hi David,

I made that change and it doesnt seem to work, with the orginal code when searching my site for "Gucci" i received ebay adds for Gucci clothes and my ads for sunglasses, however when I added the amended code I didnt receive any ebay results at all.

I tested with the original code by typing "gucci sunglasses" and received ebay and PT ads.

Thanks
Richard

Submitted by support on Fri, 2010-04-30 11:55.

Hi Richard,

Could you email me your modified ebay.php and I'll check it out for you...

Cheers,
David.

Submitted by babyuniverse on Tue, 2010-06-29 11:43.

Hi David,

I am trying to add a ebay widget to my website, which is working fine pasting the following into footer.

<script src='http://adn.ebay.com/files/js/min/ebay_activeContent-min.js'></script>
<script src='http://adn.ebay.com/cb?programId=4&campId=xxxxxx&toolId=10026&keyword=baby&width=160&height=600&font=1&textColor=333366&linkColor=333333&arrowColor=8BBC01&color1=FFFFFF&color2=FFFFFF'></script>

Just a quick question, currently keyword above is set to "baby" which is a generic term when creating the widget, would it be easy yo set keyword to match a keyword ($q) in PT.

For example, if the page is a searchresults or product page then keyword would reference them, which i believe you do checking if $q is set. If not then it defaults back to a keyword of choice.

Make sense?

Thanks
Richard

Submitted by support on Tue, 2010-06-29 11:52.

Hi Richard,

Have a go with:

<script src='http://adn.ebay.com/files/js/min/ebay_activeContent-min.js'></script>
<script src='http://adn.ebay.com/cb?programId=4&campId=xxxxxx&toolId=10026&keyword=<?php print ($q<>""?urlencode($q):"baby"); ?>&width=160&height=600&font=1&textColor=333366&linkColor=333333&arrowColor=8BBC01&color1=FFFFFF&color2=FFFFFF'></script>

(where "baby" is the default keyword(s) you want if $q is not set...)

Cheers,
David.

Submitted by babyuniverse on Wed, 2010-06-30 11:09.

Thanks again David,

Working fine, is it possible to change the default keyword to be the most searched keyword?

Submitted by support on Wed, 2010-06-30 11:16.

Should be - have a go with:

<?php
if ($q=="")
{
  $sql = "SELECT query FROM `".$config_databaseTablePrefix."querylog` ORDER BY count DESC LIMIT 1";
  database_querySelect($sql,$rows);
  $q = $rows[0]["query"];
}
?>
<script src='http://adn.ebay.com/files/js/min/ebay_activeContent-min.js'></script>
<script src='http://adn.ebay.com/cb?programId=4&campId=xxxxxx&toolId=10026&keyword=<?php print urlencode($q); ?>&width=160&height=600&font=1&textColor=333366&linkColor=333333&arrowColor=8BBC01&color1=FFFFFF&color2=FFFFFF'></script>

Cheers,
David.

Submitted by darren on Fri, 2010-09-03 08:42.

Hi David

I am using search external to show a list of products on a wordpress site but for some pages I want to only call eBay results.
Is there a way of doing this other than having a separate PT installation just for eBay?

I'm not using the eBay script at present btw - it's just a theoretical question for now.

Submitted by support on Fri, 2010-09-03 09:08.

Hi Darren,

To convert ebay.php into "ebayExternal.php", look for the following code at line 7:

  require("includes/MagicParser.php");

...and REPLACE that with:

  require($common_path."includes/MagicParser.php");

...and then call just as the other external scripts as follows;

<?php
  $common_path 
"/path/to/pricetapestry/";
  
$_GET["q"] = "Keywords";
  require(
$common_path."ebayExternal.php");
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by darren on Fri, 2010-09-03 10:04.

Thanks David
Easier than I thought.

Submitted by darren on Sun, 2010-09-05 08:42.

Afraid that doesn't work?

I have edited the file to include the details listed above and saved as ebayExternal.php

Using the code

<?php
  $common_path 
"/path-to-pt-installation/";
  
$_GET["q"] = "keyword";
  require(
$common_path."ebayExternal.php");
?>

returns nothing for any search
I tried adding "$common_baseHREF" as with other external files but this made no difference?

Any ideas?

Cheers

Submitted by support on Mon, 2010-09-06 07:53.

Hi Darren,

I just realised that ebay.php uses the tapestry_decimalise() function, so this will have to be included also. In your ebayExternal.php script, after the following line:

  require($common_path."includes/MagicParser.php");

add:

  require($common_path."includes/tapestry.php");

Cheers,
David.
--
PriceTapestry.com

Submitted by darren on Mon, 2010-09-06 10:40.

Still doesn't work?

Submitted by support on Mon, 2010-09-06 11:07.

Hi Darren,

Could you email me your ebayexternal.php and I'll check it out on my test server for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by darren on Sat, 2010-10-09 11:01.

Hi David

Thank you for sorting this out for me and for the modifications to amazon external also.

Now, I suspect there may not be a solution to this but the images returned by ebay are very poor quality. I managed to solve a similar problem with the amazon script by just changing the image code to "LARGEIMAGE/URL" and resizing as required.

Now with ebay it doesn't look so simple.
At present the image is called from "GALLERYURL" Is there an alternative?

Cheers

Darren

Submitted by support on Sat, 2010-10-09 11:42.

Hi Darren,

Bear with me and I'll setup the API call on my test server and check the response for possible alternatives...

Cheers,
David.
--
PriceTapestry.com

Submitted by support on Sat, 2010-10-09 18:30.

Hi Darren,

It looks like if a better pictures is available it will be in the GALLERYPLUSPICTUREURL field, so to use this if available, in ebay.php look for the following code at line 17:

  print "<img width='80' src='".$item["GALLERYURL"]."' />";

...and REPLACE that with:

  print "<img width='80' src='".($item["GALLERYPLUSPICTUREURL"]?$item["GALLERYPLUSPICTUREURL"]:$item["GALLERYURL"])."' />";

Cheers,
David.
--
PriceTapestry.com

Submitted by darren on Sat, 2010-10-09 20:30.

Cheers David
That certainly works where a better image is available.

Thanks very much.

Darren