<?php
$pear_path = '/path/to/pear/';
ini_set('include_path', ini_get('include_path').':'.$pear_path);
require_once 'Ebay_API.php';
$ebay = new Ebay_API;
// Set application to connect to eBay Sandbox environment
$ebay->setMode('test');
$eBayUserId = ''; // Declare a valid eBay UserId here
$eBayPasswd = ''; // Declare the password for the eBayUserId
// Prepare the application so all requests can be verified
$ebay->setAppCredentials($eBayUserId, $eBayPasswd);
$eBayAppConfig = array(
'X-EBAY-API-COMPATIBILITY-LEVEL' => '349',
'X-EBAY-API-DEV-NAME' => '', // Insert your eBay DevId here
'X-EBAY-API-APP-NAME' => '', // Insert your eBay AppId here
'X-EBAY-API-CERT-NAME' => '', // Insert your eBay CertId here
);
// Setup the headers required for the HTTPS request
$ebay->setAppHeaders($eBayAppConfig);
// Some pre configured test commands
//$executeCommand = 'GeteBayDetails';
//$executeCommand = 'GetCategories';
$executeCommand = 'GeteBayOfficialTime';
// An array of commands and paramaters associated with those commands
$eBayCommand = array(
'GetCategories' => array( 'command' => 'GetCategories',
'paramaters' => array(
'DetailLevel' => 1,
'LevelLimit' => 1,
'CategorySiteId' => 0,
'ViewAllNodes' => 1,
),
),
'GeteBayDetails' => array( 'command' => 'GeteBayDetails',
'paramaters' => array(),
),
'GeteBayOfficialTime'] = array( 'command' => 'GeteBayOfficialTime',
'paramaters' => array(),
),
);
// Define the eBay SiteId to access - 0 = US (ebay.com)
$siteId = 0;
if ( Ebay_API::isError($eBayResponse = $ebay->sendRequest($eBayCommand[$executeCommand]['command'], $eBayCommand[$executeCommand]['paramaters'], $siteId)) ) {
echo '<PRE>';
var_dump($eBayResponse);
echo '</PRE>';
} else {
// Show some basic output from the eBay Response
switch ( $executeCommand ) {
case 'GetCategories':
echo 'Current eBay Time: '.Ebay_API::getFromResponse($eBayResponse, 'EBayTime').'<BR>';
echo 'Last Category Update: '.Ebay_API::getFromResponse($eBayResponse, 'Categories.UpdateTime').'<BR>';
break;
case 'GeteBayDetails':
break;
case 'GeteBayOfficialTime':
echo 'Current eBay Time: '.Ebay_API::getFromResponse($eBayResponse ,'EBayTime').'<BR>';
break;
}
}
?>