NAME

WebService::eBay

SYNOPSIS

This package provides an interface to use the eBay Trading API. For more information about the eBay Trading API, visit https://developer.ebay.com/devzone/xml/docs/reference/ebay/index.html

The "hello world" equivalent in the eBay API world is to send a call asking for the current eBay time. Here's an example of how to do that with this module:

use WebService::eBay;

my $response = WebService::eBay::APICall("GeteBayOfficialTime");
print "$response->{Timestamp}\n";

But this isn't a great example for this module because the GeteBayOfficialTime call doesn't take any parameters. A simple one that does though is the EndItem call. Here's how you would do that in this module:

my $listingNumber = '142306955';
my $callDetails   = "<ItemID>$listingNumber</ItemID>
<EndingReason>OtherListingError</EndingReason>";

if ( WebService::eBay::APICall( "EndItem", $callDetails ) ) {
	print "\nDeleted $listingNumber from eBay\n";
} else {
	print("\nUnable to end listing $listingNumber\n");
}

DESCRIPTION

To use the eBay Trading API you need application keys and an authorization token. You can obtain these through your eBay developer account. You should create a file called "tokens" in the directory containing the program using this module. That file should look like this for the API sandbox and testing:

APIURL https://api.sandbox.ebay.com/ws/api.dll
SiteID 0
DevName <Your Dev Name>
AppName <Your App Name>
CertName <Your Cert Name>
AuthToken <Your Auth Token>
Log true

and this for the Production keys.

APIURL https://api.ebay.com/ws/api.dll
SiteID 100
DevName <Your Dev Name>
AppName <Your App Name>
CertName <Your Cert Name>
AuthToken <Your Auth Token>

The last option "Log" is intended for testing and sandbox use as it logs all communication sent and received from the API, which includes your secret keys. To not use this option, leave the "Log" line out of the tokens file or set it to something other than 'true'.

SUBROUTINES

APICall

Sends an API call and returns the results as a hash. Optionally returns the raw XML. If the call encounters an HTTP error sending the call, it will try again twice before giving up. This is in accordance with the rules for the eBay API.

Parameters

CallName

The name of the API Call that you wish to make. For a list of API calls and their parameters, visit https://developer.ebay.com/devzone/xml/docs/reference/ebay/index.html

RequestDetails

The details of the call, in XML. You do not need to provide the RequesterCredentials or the WarningLevel, but you do have to provide the rest of the call. This is where that goes. The RequesterCredentials are always the same and the WarningLevel doesn't usually need to be changed. For information on what details your call needs, visit https://developer.ebay.com/devzone/xml/docs/reference/ebay/index.html

Some calls have no details, such as GeteBayOfficialTime.

Xml

Pass any value here for true (pass "undef" for false) and the sub will return the raw XML from the API response, instead of the hash.

FailOnWarning

Pass any value here for true (pass "undef" for false) and the sub will return false ("fail") if the API call returns a warning. The default is to return the hash (which contains the warning) if the API call returns a warning.

GeteBayTime

Returns eBay official time. Not local time.

Parameters

FormateBayDate

Returns the current date formatted for use in eBay API calls. Optionally will return a date offset from the current time, such as one hour from now or one day ago.

Parameters

Offset

Number of seconds to offset the current time. Example: FormateBayDate(3600) returns the time one hour from now. This function is usually called as FormateBayDate(86400) to obtain the next day's date.

XMLClean

Strips a string of characters recognized by XML code

Parameters

Line

The string of characters you want to process.

GetUUID

Returns a UUID formatted for eBay standards

Parameters

none

ebayTimeToSqlTimestamp

Converts an ebay time to a string properly formatted for insertion as an SQL timestamp.

Parameters

time

The time you want to convert