public function init($logLevel = 0, $configFile) { if ($logLevel >= 1) { $this->logger = new EbatNs_Logger(); } $this->configFile = $configFile; $this->session = new EbatNs_Session($this->configFile); $this->proxy = new EbatNs_ServiceProxy($this->session); if ($this->logger) { $this->proxy->attachLogger($this->logger); } }
/*auctions_getItem.php*/ require 'includes/application_top.php'; // include needed functions require_once $ebatns_dir . 'EbatNs_ServiceProxy.php'; require_once $ebatns_dir . 'EbatNs_Logger.php'; require_once $ebatns_dir . 'GetItemRequestType.php'; require_once $ebatns_dir . 'ItemType.php'; $session = create_ebay_session(); if ($session) { $cs = new EbatNs_ServiceProxy($session); $cs->setHandler('ItemType', 'handleItem'); $logger = new EbatNs_Logger(true); // $logger->_debugXmlBeautify = true; // $logger->_debugSecureLogging = false; $cs->attachLogger($logger); $req = new GetItemRequestType(); $req->setItemID($_GET['itemId']); $req->setDetailLevel($Facet_DetailLevelCodeType->ReturnAll); $res = $cs->GetItem($req); echo "<pre>"; if ($res->getAck() != $Facet_AckCodeType->Success) { echo "we got a failure<br/>"; foreach ($res->getErrors() as $error) { echo "#" . $error->getErrorCode() . " " . htmlentities($error->getShortMessage()) . "/" . htmlentities($error->getLongMessage()) . HTML_BR; } } else { //#type $item ItemType $item = $res->getItem(); echo "ShippingTerms : " . $item->getShippingTerms() . HTML_BR; print_r($item);
public function initEbay($site_id, $sandbox_enabled, $token = false, $account_id = false) { // init autoloader fro EbatNs classes $this->loadEbayClasses(); WPLE()->logger->info("initEbay( {$account_id} )"); // require_once 'EbatNs_ServiceProxy.php'; // require_once 'EbatNs_Logger.php'; // hide inevitable cURL warnings from SDK // *** DISABLE FOR DEBUGGING *** $this->error_reporting_level = error_reporting(); WPLE()->logger->debug('original error reporting level: ' . $this->error_reporting_level); // // regard php_error_handling option // // first bit (1) will show all php errors if set // if ( 1 & get_option( 'wplister_php_error_handling', 0 ) ) { // error_reporting( E_ALL | E_STRICT ); // } else { // // only show fatal errors (default) // error_reporting( E_ERROR ); // } error_reporting(E_ERROR); WPLE()->logger->debug('new error reporting level: ' . error_reporting()); $this->siteId = $site_id; $this->sandbox = $sandbox_enabled; #$this->compLevel = 765; if ($sandbox_enabled) { // sandbox keys $this->devId = 'db0c17b6-c357-4a38-aa60-7e80158f57dc'; $this->appId = 'LWSWerbu-c159-4552-8411-1406ca5a2bba'; $this->certId = '33272b6e-ef02-4d22-a487-a1a3f02b9c66'; $this->RuName = 'LWS_Werbung_Gmb-LWSWerbu-c159-4-tchfyrowj'; $this->apiurl = 'https://api.sandbox.ebay.com/ws/api.dll'; $this->signin = 'https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn&'; } else { // production keys $this->devId = 'db0c17b6-c357-4a38-aa60-7e80158f57dc'; $this->appId = 'LWSWerbu-6147-43ed-9835-853f7b5dc6cb'; $this->certId = '61212d27-f74b-416b-8d48-3160f245443f'; $this->RuName = 'LWS_Werbung_Gmb-LWSWerbu-6147-4-ywstl'; $this->apiurl = 'https://api.ebay.com/ws/api.dll'; $this->signin = 'https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&'; } // filter RuName if (defined('WPLISTER_RESELLER_VERSION')) { $this->RuName = apply_filters('wplister_runame', $this->RuName, $sandbox_enabled); } // init session $session = new EbatNs_Session(); // depends on the site working on (needs ID-Value !) $session->setSiteId($site_id); $session->wple_account_id = $account_id; // regard WP proxy server if (defined('WP_USEPROXY') && WP_USEPROXY) { if (defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT')) { $session->setProxyServer(WP_PROXY_HOST . ':' . WP_PROXY_PORT); } } // environment (0=production, 1=sandbox) if ($sandbox_enabled == '1') { WPLE()->logger->info('initEbay(): SANDBOX ENABLED'); $session->setAppMode(1); // this must be set *before* setting the keys (appId, devId, ...) } else { $session->setAppMode(0); } $session->setAppId($this->appId); $session->setDevId($this->devId); $session->setCertId($this->certId); if ($token) { // use a token as credential $session->setTokenMode(true); // do NOT use a token file ! $session->setTokenUsePickupFile(false); // token of the user $session->setRequestToken($token); } else { $session->setTokenMode(false); } // creating a proxy for UTF8 $sp = new EbatNs_ServiceProxy($session, 'EbatNs_DataConverterUtf8'); // // logger doc: http://www.intradesys.com/de/forum/1528 // if ( get_option('wplister_log_level') > 5 ) { // #$sp->attachLogger( new EbatNs_Logger(false, 'stdout', true, false) ); // $sp->attachLogger( new EbatNs_Logger(false, WPLE()->logger->file ) ); // } // attach custom DB Logger for Tools page // if ( get_option('wplister_log_to_db') == '1' ) { if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'wplister-tools') { $sp->attachLogger(new WPL_EbatNs_Logger(false, 'db', $account_id, $site_id)); } // save service proxy - and session $this->sp = $sp; $this->session = $session; }