function create_ebay_session() { /* Site-id 0: ebay.com Site-id 2: ebay.ca Site-id 3: ebay.co.uk Site-id 15: ebay.au Site-id 16: ebay.at Site-id 23: ebay.be Site-id 71: ebay.fr Site-id 77: ebay.de Site-id 100: ebaymotors.com Site-id 101: ebay.it Site-id 123: ebay.be Site-id 146: ebay.nl Site-id 186: ebay.es Site-id 193: ebay.ch Site-id 196: ebay.tw Site-id 201: ebay.hk Site-id 203: ebay.in Site-id 207: ebay.my Site-id 211: ebay.ph Site-id 212: ebay.pl Site-id 216: ebay.sg Site-id 218: ebay.se Site-id 223: ebay.cn */ $site_id = 77; //ebay.de $app_mode = EBAY_TEST_MODE == TRUE_STRING_S; if ($app_mode) { if (defined('EBAY_TEST_MODE_DEVID') && defined('EBAY_TEST_MODE_APPID') && defined('EBAY_TEST_MODE_CERTID') && defined('EBAY_TEST_MODE_TOKEN')) { $devid = EBAY_TEST_MODE_DEVID; $appid = EBAY_TEST_MODE_APPID; $certid = EBAY_TEST_MODE_CERTID; $token = EBAY_TEST_MODE_TOKEN; } } else { if (defined('EBAY_PRODUCTION_DEVID') && defined('EBAY_PRODUCTION_APPID') && defined('EBAY_PRODUCTION_CERTID') && defined('EBAY_PRODUCTION_TOKEN')) { $devid = EBAY_PRODUCTION_DEVID; $appid = EBAY_PRODUCTION_APPID; $certid = EBAY_PRODUCTION_CERTID; $token = EBAY_PRODUCTION_TOKEN; } } if ($devid && $appid && $certid && $token) { $ebsession = new EbatNs_Session(); $ebsession->setDevId($devid); $ebsession->setAppId($appid); $ebsession->setCertId($certid); $ebsession->setSiteId($site_id); $ebsession->setAppMode($app_mode); $ebsession->setUseHttpCompression(true); // switch to token-mode $ebsession->setTokenMode(1); // do NOT read the token from the file $ebsession->setTokenUsePickupFile(false); $ebsession->setRequestToken($token); return $ebsession; } else { return false; } }
/** * * @access public * @param string $configFile * @return void */ function EbatNs_Session($configFile = null) { // call to initialisation // (be sure to call this always on the actual class and prevent any overwriting) EbatNs_Session::_init(); $this->_props['RequestToken'] = EBAY_NOTHING; if ($configFile != null) { $this->InitFromConfig($configFile); } }
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; }