For our geeXapp application, we had to implement the attribute based item specifics in the eBay API. Rather than build something directly into the framework, we thought it would be convenient to build a category selector XML API that anyone could use (without eBay credentials) -- saving some implementation time.
This is it, but we're offering this with limited documentation because it's pretty self explanatory.
The URL for the API is http://ebayis.geexapp.com/. A total of 3 GET variables are used, as well as one POST variable (for prefilling the form with attributes that a user has already selected).
GET['Category1']: The eBay category number of the primary category a user is selecting specifics for GET['Category2']: The eBay category number of the secondary category a user is selecting specifics for GET['Capture']: If set to 1, the application will output only the XML (rawurlencoded in PHP) that would be passed into thenode in the AddItem call POST['rawXml']: The exact same string returned when GET['Capture'] was 1. Post it back in this variable, and the form will prepopulate.
Try it for the Cell Phone category (3312)!
Currently only eBay US is supported, and only attribute-based specifics, but eBay Motors and custom specifics should come along soon.
Also, if you want a JavaScript widget selector, we have that too. Simply simply down these 2 files:
Then create a "redirect.php" file somewhere on your server with the following in it:
<?php
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'geexapp-item-specifics') { header('Location: http://ebayis.geexapp.com/',true,301); }
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, 'http://ebayis.geexapp.com/?Category1='.(int)$_GET['Category1'].'&Category2='.(int)$_GET['Category2'].'&Capture='.(int)$_GET['Capture']);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, @file_get_contents('php://input'));
echo curl_exec ($ch);
The redirect.php file is required because the category selector uses AJAX, and AJAX calls must be made within the same domain. Your webserver must have PHP enabled with cURL installed. Once the file is in place, modify the variable 'self.baseUrl' in item-specifics.js to point to that file.
Include the item-specifics.css stylesheet and item-specifics.js script in your website header. Then, to activate a selector, use code something like:
var myVar = new itemSpecifics (objForOutput,optionalObjectContainer); myVar.fetch (0);
When the user selects a category, the objects you passed will have their innerHTML and value set as follows:
objForOutput: The rawurlencoded item specifics string mentioned above in the GET['capture'] notes optionalObjectContainer: By default, the selector object is appended to the document body. If an object is passed here, it will be used instead.
That's all there is to it! The code should be relatively straightforward to modify to suit your needs. Otherwise, it is offered free to use and modify for all, but without warranty, etc.