NAME
Net::eBay - Perl Interface to XML based eBay API.
VERSION
Version 0.62
SYNOPSIS
This module helps user to easily execute queries against eBay's XML API. Copyright Igor Chudov, ichudov@algebra.com. Released under GNU Public License v. 2
##################################################
# For support, docs, info, email to author go to #
# #
# http://www.net-ebay.org/ #
##################################################
Also check out Object::eBay perl module for higher level abstraction built on top of Net::eBay. Object::eBay is a work of another individual, not Igor Chudov.
Also check out several ebay-*.pl scripts that ship with this distribution, they should be installed in your scripts directory.
Getting Official Time
use Net::eBay;
my $eBay = new Net::eBay; # look up ebay.ini in $ENV{EBAY_INI_FILE}, "./ebay.ini", "~/.ebay.ini"
my $result = $eBay->submitRequest( "GeteBayOfficialTime", {} );
print "eBay Official Time = $result->{EBayTime}.\n";
Automated bidding
eBay does not allow bidding via eBay API.
Listing Item for sale
use Net::eBay;
use Data::Dumper;
# another way of creating Net::eBay object.
my $ebay = new Net::eBay( {
SiteLevel => 'prod',
DeveloperKey => '...',
ApplicationKey => '...',
CertificateKey => '...',
Token => '...',
} );
my $result = $ebay->submitRequest( "AddItem",
{
DetailLevel => "0",
ErrorLevel => "1",
SiteId = > "0",
Verb => " AddItem",
Category => "14111",
CheckoutDetailsSpecified => "0",
Country => "us",
Currency => "1",
Description => "For sale is like new <A HREF=http://www.example.com/jhds/>thingamabob</A>.Shipping is responsibility of the buyer.",
Duration => "7",
Location => "Anytown, USA, 43215",
Gallery => 1,
GalleryURL => 'http://igor.chudov.com/images/mark_mattson.jpg',
MinimumBid => "0.99",
BuyItNowPrice => 19.99,
PayPalAccepted => "1",
PayPalEmailAddress => "ichudov\@example.com",
Quantity => "1",
Region => "60",
Title => "Igor's Item with Gallery xaxa",
}
);
print "Result: " . Dumper( $result ) . "\n";
Result of submitRequest is a perl hash obtained from the response XML using XML::Simple, something like this:
Result: $VAR1 = {
'Item' => {
'Id' => '4503546598',
'Fees' => {
'FeaturedGalleryFee' => '0.00',
'InternationalInsertionFee' => '0.00',
'CurrencyId' => '1',
'GalleryFee' => '0.25',
'AuctionLengthFee' => '0.00',
'ProPackBundleFee' => '0.00',
'BorderFee' => '0.00',
'FeaturedFee' => '0.00',
'SchedulingFee' => '0.00',
'HighLightFee' => '0.00',
'FixedPriceDurationFee' => '0.00',
'PhotoDisplayFee' => '0.00',
'ListingFee' => '0.55',
'BuyItNowFee' => '0.00',
'PhotoFee' => '0.00',
'GiftIconFee' => '0.00',
'SubtitleFee' => '0.00',
'InsertionFee' => '0.30',
'ListingDesignerFee' => '0.00',
'BoldFee' => '0.00',
'ReserveFee' => '0.00',
'CategoryFeaturedFee' => '0.00'
},
'StartTime' => '2005-08-30 04:50:47',
'EndTime' => '2005-09-06 04:50:47'
},
'EBayTime' => '2005-08-30 04:50:47'
};
See an alternative example of submitting an item using New Schema, in script ebay-add-item.pl.
If an error in parsing XML occurs, result will be simply the string that is the text representation of the answer.
EXPORT
new -- creates eBay API. Requires supplying of credentials: DeveloperKey, ApplicationKey, CertificateKey, Token. Net::eBay will not be created until these keys and the token are supplied.
Get them by registering at http://developer.ebay.com and self certifying. Celf certifying is a trivial process of solemnly swearing that you are ready to use their API.
The SiteLevel parameter is also mandatory and can be either 'prod' or 'dev'. prod means to use their production site (being charged real money for listings, etc), and dev means to use eBay sandbox http://sandbox.ebay.com/.
Parameters can be supplied in two ways:
1) As a hash table
2) As a filename (only argument). If filename and hash are missing, Net::eBay makes an effort to fine a ebay.ini file by looking for: $ENV{EBAY_INI_FILE}, ./ebay.ini, ~/.ebay.ini . That's the default constructor.
See SAMPLE.ebay.ini in this distribution.
Defaults and XML API Versions
This module, by default, is using the "Legacy XML API" that is set to expire in the summer of 2006. That default will change as the legacy API actually expires.
XML API Schema is set by calling setDefaults( { ... } )
See its documentation below.
ebay.ini FILE
ebay.ini is a file that lists ebay access keys and whether this is for accessing eBay production site or its developers' sandbox. Example of the file (see SAMPLE.ebay.ini):
# dev or prod
SiteLevel=prod
# your developer key
DeveloperKey=KLJHAKLJHLKJHLKJH
# your application key
ApplicationKey=LJKGHKLJGKJHG
# your certificate key
CertificateKey=SUYTYWTKWTYIUYTWIUTY
# your token (a very BIG string)
Token=JKHGHJGJHGKJHGKJHGkluhsdihdsriuhfwe87yr8wehIEWH9O78YWERF90HF9UHJESIPHJFV94Y4089734Y
This module was seen times.
FUNCTIONS
new
setDefaults
Sets application defaults, most importantly the XML API version to be used.
Takes a hash argument.
The following defaults can be set:
* API -- sets eBay API version. Only two values are supported: '1' means Legacy API set to expire in the summer of 2006, '2' means the API that supersedes it. All other values are illegal.
* debug -- if debug is set to true, prints a lot of debugging information, XML sent and received etc.
* siteid -- sets site id
* compatibility -- "compatibility level" with eBay. Set to a sensible default.
* timeout -- sets default query timeout, default is 50 seconds
* retries -- sets the number of times a failed request should be retried. Defaults to 2 according to http://xrl.us/bk7vb This only retries requests where eBay is to blame for the failure. Faulty API requests are not retried.
Example:
$eBay->setDefaults( { API => 2 } ); # use new eBay API
$eBay->setDefaults( { API => 2, debug => 1 } ); # use new eBay API and also debug all calls
submitRequest
Sends a request to eBay. Takes a name of the API call and a hash of arguments. The arguments can be hashes of hashes and are properly translated into nested XML structures.
Example:
TopLevel => {
Item1 => 'hello',
Item2 => 'world'
Item3 => ['foo', 'bar']
}
it would be translated to
<TopLevel>
<Item1>hello</Item1>
<Item2>world</Item2>
<Item3>foo</Item3>
<Item3>bar</Item3>
</TopLevel>
If an argument has XML attributes and should be formatted like this:
<TestAttribute currencyID="USD" >abcd</TestAttribute>
(note "currencyID")
your argument should be
TestAttribute => { _attributes => { currencyID => 'USD' }, _value => 'abcd' ),
Depending on the default API set by setDefaults (see above), XML produced will be compatible with the eBay API version selected by the user.
officialTime
Returns eBay official time
UTF8 Internal ONLY function
hash2xml Internal ONLY function
submitRequestGetText Internal ONLY function
verifyAndPrint Internal ONLY function
AUTHOR
Igor Chudov, <ichudov@algebra.com>
BUGS
Please report any bugs or feature requests to bug-net-ebay@rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-eBay. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2005 Igor Chudov, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.