/framework/EbatNs_Session.php

https://github.com/iloveitaly/ebay-php · PHP · 1185 lines · 519 code · 3 blank · 663 comment · 43 complexity · a9a5b53adcf23cf404f8d914ab67d2b2 MD5 · raw file

  1. <?php
  2. // $Id: EbatNs_Session.php,v 1.4 2008/06/09 10:29:36 michael Exp $
  3. // $Log: EbatNs_Session.php,v $
  4. // Revision 1.4 2008/06/09 10:29:36 michael
  5. // *** empty log message ***
  6. //
  7. // Revision 1.3 2008/05/04 15:24:03 carsten
  8. // *** empty log message ***
  9. //
  10. // Revision 1.2 2008/05/02 15:04:05 carsten
  11. // Initial, PHP5
  12. //
  13. //
  14. require_once 'EbatNs_Defines.php';
  15. class EbatNs_Session {
  16. // this array holds all attribute data of the object
  17. protected $_props = array();
  18. /**
  19. * sets a property by name and value
  20. */
  21. function _setProp($key, $value)
  22. {
  23. $this->_props[$key] = $value;
  24. }
  25. /**
  26. * gets a property by name
  27. */
  28. function _getProp($key)
  29. {
  30. return $this->_props[$key];
  31. }
  32. /**
  33. * Read accessor of AppId.
  34. * The value of this property is used as the application ID in each XML request sent to the eBay API.
  35. *
  36. * @access public
  37. * @return string Value of the AppId property
  38. */
  39. function getAppId()
  40. {
  41. return $this->_props['AppId'];
  42. }
  43. /**
  44. * Write accessor of AppId.
  45. * The value of this property is used as the application ID in each XML request sent to the eBay API.
  46. *
  47. * @access public
  48. * @param string $value The new value for the AppId property
  49. * @return void
  50. */
  51. function setAppId($value)
  52. {
  53. $this->_props['AppId'] = $value;
  54. }
  55. /**
  56. * Read accessor of DevId.
  57. * The value of this property is used as the developer ID in each XML request sent to the eBay API.
  58. *
  59. * @access public
  60. * @return string Value of the DevId property
  61. */
  62. function getDevId()
  63. {
  64. return $this->_props['DevId'];
  65. }
  66. /**
  67. * Write accessor of DevId.
  68. * The value of this property is used as the developer ID in each XML request sent to the eBay API.
  69. *
  70. * @access public
  71. * @param string $value The new value for the DevId property
  72. * @return void
  73. */
  74. function setDevId($value)
  75. {
  76. $this->_props['DevId'] = $value;
  77. }
  78. /**
  79. * Read accessor of CertId.
  80. * The value of this property is used as the security certificate in each XML request sent to the eBay API.
  81. *
  82. * @access public
  83. * @return string Value of the CertId property
  84. */
  85. function getCertId()
  86. {
  87. return $this->_props['CertId'];
  88. }
  89. /**
  90. * Write accessor of CertId.
  91. * The value of this property is used as the security certificate in each XML request sent to the eBay API.
  92. *
  93. * @access public
  94. * @param string $value The new value for the CertId property
  95. * @return void
  96. */
  97. function setCertId($value)
  98. {
  99. $this->_props['CertId'] = $value;
  100. }
  101. /**
  102. * Read accessor of RequestPassword.
  103. * Specifies the password for the user making the API call. This value is sent in the <RequestPassword> element.
  104. *
  105. * @access public
  106. * @return string Value of the RequestPassword property
  107. */
  108. function getRequestPassword()
  109. {
  110. return $this->_props['RequestPassword'];
  111. }
  112. /**
  113. * Write accessor of RequestPassword.
  114. * Specifies the password for the user making the API call. This value is sent in the <RequestPassword> element.
  115. *
  116. * @access public
  117. * @param string $value The new value for the RequestPassword property
  118. * @return void
  119. */
  120. function setRequestPassword($value)
  121. {
  122. $this->_props['RequestPassword'] = $value;
  123. }
  124. /**
  125. * Read accessor of RequestUser.
  126. * Specifies the user ID making the API call. This value is sent in the <RequestUserId> element.
  127. *
  128. * @access public
  129. * @return string Value of the RequestUser property
  130. */
  131. function getRequestUser()
  132. {
  133. return $this->_props['RequestUser'];
  134. }
  135. /**
  136. * Write accessor of RequestUser.
  137. * Specifies the user ID making the API call. This value is sent in the <RequestUserId> element.
  138. *
  139. * @access public
  140. * @param string $value The new value for the RequestUser property
  141. * @return void
  142. */
  143. function setRequestUser($value)
  144. {
  145. $this->_props['RequestUser'] = $value;
  146. }
  147. /**
  148. * Read accessor of TimeOffset.
  149. * Time offset of the local machine from eBay official time. Whenever using Timestamps on any calls (in and out) the information will be adapted with this value.
  150. * Please provide a string with relative information e.g. "+0200" for a timezone which is 2 hours infront of GMT
  151. *
  152. * @access public
  153. * @return string Value of the TimeOffset property
  154. */
  155. function getTimeOffset()
  156. {
  157. return $this->_props['TimeOffset'];
  158. }
  159. /**
  160. * Write accessor of TimeOffset.
  161. * Time offset of the local machine from eBay official time. Whenever using Timestamps on any calls (in and out) the information will be adapted with this value.
  162. * Please provide a string with relative information e.g. "+0200" for a timezone which is 2 hours infront of GMT
  163. *
  164. * @access public
  165. * @param string $value The new value for the TimeOffset property
  166. * @return void
  167. */
  168. function setTimeOffset($value)
  169. {
  170. $this->_props['TimeOffset'] = $value;
  171. }
  172. /**
  173. * Read accessor of LogLevel.
  174. * Define the amount og information being logged to the LogFile. Use one of the following defines (or an AND combined value) :
  175. *
  176. * @access public
  177. * @return number Value of the LogLevel property
  178. */
  179. function getLogLevel()
  180. {
  181. return $this->_props['LogLevel'];
  182. }
  183. /**
  184. * Write accessor of LogLevel.
  185. * Define the amount og information being logged to the LogFile. Use one of the following defines (or an AND combined value) :
  186. *
  187. * @access public
  188. * @param number $value The new value for the LogLevel property
  189. * @return void
  190. */
  191. function setLogLevel($value)
  192. {
  193. $this->_props['LogLevel'] = $value;
  194. }
  195. /**
  196. * Read accessor of LogFilename.
  197. * Filename of the log-file. If the log-fle does not exits it will be created otherwise data gets appended. Be sure of setting write-permission to the user the php process is running as (aka www).
  198. * Should install a mechanism to delete or roll the file once a time to not screw up your system.
  199. *
  200. * @access public
  201. * @return string Value of the LogFilename property
  202. */
  203. function getLogFilename()
  204. {
  205. return $this->_props['LogFilename'];
  206. }
  207. /**
  208. * Write accessor of LogFilename.
  209. * Filename of the log-file. If the log-fle does not exits it will be created otherwise data gets appended. Be sure of setting write-permission to the user the php process is running as (aka www).
  210. * Should install a mechanism to delete or roll the file once a time to not screw up your system.
  211. *
  212. * @access public
  213. * @param string $value The new value for the LogFilename property
  214. * @return void
  215. */
  216. function setLogFilename($value)
  217. {
  218. $this->_props['LogFilename'] = $value;
  219. }
  220. /**
  221. * Read accessor of LogMode.
  222. * defines how to log, actually same as define in build-in error_log function :
  223. * 0 log to syslog (or event log on winnt)
  224. * 1 email (set in LogFileName)
  225. * 2 debugger port (set in LogFileName)
  226. * 3 file (set in LogFileName)
  227. *
  228. * @access public
  229. * @return number Value of the LogMode property
  230. */
  231. function getLogMode()
  232. {
  233. return $this->_props['LogMode'];
  234. }
  235. /**
  236. * Write accessor of LogMode.
  237. * defines how to log, actually same as define in build-in error_log function :
  238. * 0 log to syslog (or event log on winnt)
  239. * 1 email (set in LogFileName)
  240. * 2 debugger port (set in LogFileName)
  241. * 3 file (set in LogFileName)
  242. *
  243. * @access public
  244. * @param number $value The new value for the LogMode property
  245. * @return void
  246. */
  247. function setLogMode($value)
  248. {
  249. $this->_props['LogMode'] = $value;
  250. }
  251. /**
  252. * Read accessor of ApiMode.
  253. * Defines how data is accessed. Mainly switch between direct and integration access through a local datastorage. Use one of the following:
  254. * EBAY_CALLMODE_DIRECT = 0
  255. * EBAY_CALLMODE_INTEGRATION = 1
  256. *
  257. * @access public
  258. * @return define Value of the ApiMode property
  259. */
  260. function getApiMode()
  261. {
  262. return $this->_props['ApiMode'];
  263. }
  264. /**
  265. * Write accessor of ApiMode.
  266. * Defines how data is accessed. Mainly switch between direct and integration access through a local datastorage. Use one of the following:
  267. * EBAY_CALLMODE_DIRECT = 0
  268. * EBAY_CALLMODE_INTEGRATION = 1
  269. *
  270. * @access public
  271. * @param define $value The new value for the ApiMode property
  272. * @return void
  273. */
  274. function setApiMode($value)
  275. {
  276. $this->_props['ApiMode'] = $value;
  277. }
  278. /**
  279. * Read accessor of SiteId.
  280. * Defines the eBay Site from or to data will be sent. Use a numeric value or one of the following defines :
  281. * EBAY_SITE_GERMANY
  282. * EBAY_SITE_US
  283. * EBAY_SITE_ ...
  284. *
  285. * @access public
  286. * @return number Value of the SiteId property
  287. */
  288. function getSiteId()
  289. {
  290. return $this->_props['SiteId'];
  291. }
  292. /**
  293. * Write accessor of SiteId.
  294. * Defines the eBay Site from or to data will be sent. Use a numeric value or one of the following defines :
  295. * EBAY_SITE_GERMANY
  296. * EBAY_SITE_US
  297. * EBAY_SITE_ ...
  298. *
  299. * @access public
  300. * @param number $value The new value for the SiteId property
  301. * @return void
  302. */
  303. function setSiteId($value)
  304. {
  305. $this->_props['SiteId'] = $value;
  306. }
  307. /**
  308. * Read accessor of CompatibilityLevel.
  309. *
  310. * @access public
  311. * @return string Value of the CompatibilityLevel property
  312. */
  313. function getCompatibilityLevel()
  314. {
  315. return $this->_props['CompatibilityLevel'];
  316. }
  317. /**
  318. * Write accessor of CompatibilityLevel.
  319. *
  320. * @access public
  321. * @param string $value The new value for the CompatibilityLevel property
  322. * @return void
  323. */
  324. function setCompatibilityLevel($value)
  325. {
  326. $this->_props['CompatibilityLevel'] = $value;
  327. }
  328. /**
  329. * Read accessor of ErrorLevel.
  330. *
  331. * @access public
  332. * @return number Value of the ErrorLevel property
  333. */
  334. function getErrorLevel()
  335. {
  336. return $this->_props['ErrorLevel'];
  337. }
  338. /**
  339. * Write accessor of ErrorLevel.
  340. *
  341. * @access public
  342. * @param number $value The new value for the ErrorLevel property
  343. * @return void
  344. */
  345. function setErrorLevel($value)
  346. {
  347. $this->_props['ErrorLevel'] = $value;
  348. }
  349. /**
  350. * Read accessor of ErrorLanguage.
  351. *
  352. * @access public
  353. * @return number Value of the ErrorLanguage property
  354. */
  355. function getErrorLanguage()
  356. {
  357. return $this->_props['ErrorLanguage'];
  358. }
  359. /**
  360. * Write accessor of ErrorLanguage.
  361. *
  362. * @access public
  363. * @param number $value The new value for the ErrorLanguage property
  364. * @return void
  365. */
  366. function setErrorLanguage($value)
  367. {
  368. $this->_props['ErrorLanguage'] = $value;
  369. }
  370. /**
  371. * Read accessor of RequestTimeout.
  372. *
  373. * @access public
  374. * @return number Value of the RequestTimeout property
  375. */
  376. function getRequestTimeout()
  377. {
  378. return $this->_props['RequestTimeout'];
  379. }
  380. /**
  381. * Write accessor of RequestTimeout.
  382. *
  383. * @access public
  384. * @param number $value The new value for the RequestTimeout property
  385. * @return void
  386. */
  387. function setRequestTimeout($value)
  388. {
  389. $this->_props['RequestTimeout'] = $value;
  390. }
  391. /**
  392. * Read accessor of TokenMode.
  393. *
  394. * @access public
  395. * @return boolean Value of the TokenMode property
  396. */
  397. function getTokenMode()
  398. {
  399. return $this->_props['TokenMode'];
  400. }
  401. /**
  402. * Write accessor of TokenMode.
  403. *
  404. * @access public
  405. * @param boolean $value The new value for the TokenMode property
  406. * @return void
  407. */
  408. function setTokenMode($value)
  409. {
  410. $this->_props['TokenMode'] = $value;
  411. }
  412. /**
  413. * Read accessor of TokenPickupFile.
  414. * will be used to pickup / store the token information for this session
  415. *
  416. * @access public
  417. * @return string Value of the TokenPickupFile property
  418. */
  419. function getTokenPickupFile()
  420. {
  421. return $this->_props['TokenPickupFile'];
  422. }
  423. /**
  424. * Write accessor of TokenPickupFile.
  425. * will be used to pickup / store the token information for this session
  426. *
  427. * @access public
  428. * @param string $value The new value for the TokenPickupFile property
  429. * @return void
  430. */
  431. function setTokenPickupFile($value)
  432. {
  433. $this->_props['TokenPickupFile'] = $value;
  434. }
  435. /**
  436. * Read accessor of TokenUsePickupFile.
  437. *
  438. * @access public
  439. * @return boolean Value of the TokenUsePickupFile property
  440. */
  441. function getTokenUsePickupFile()
  442. {
  443. return $this->_props['TokenUsePickupFile'];
  444. }
  445. /**
  446. * Write accessor of TokenUsePickupFile.
  447. *
  448. * @access public
  449. * @param boolean $value The new value for the TokenUsePickupFile property
  450. * @return void
  451. */
  452. function setTokenUsePickupFile($value)
  453. {
  454. $this->_props['TokenUsePickupFile'] = $value;
  455. }
  456. /**
  457. * Read accessor of ApiUrl.
  458. * returns the API Url
  459. *
  460. * @access public
  461. * @return string Value of the ApiUrl property
  462. */
  463. function getApiUrl()
  464. {
  465. return $this->_props['ApiUrl'];
  466. }
  467. /**
  468. * Write accessor of ApiUrl.
  469. * returns the API Url
  470. *
  471. * @access public
  472. * @param string $value The new value for the ApiUrl property
  473. * @return void
  474. */
  475. function setApiUrl($value)
  476. {
  477. $this->_props['ApiUrl'] = $value;
  478. }
  479. /**
  480. * Read accessor of AppMode.
  481. * defines which API server to call
  482. * EBAY_APPMODE_SANDBOX = 1
  483. * EBAY_APPMODE_QA = 2
  484. * EBAY_APPMODE_PRODUCTION = 0
  485. * EBAY_APPMODE_LOCALDEBUG = 100
  486. *
  487. * @access public
  488. * @return define Value of the AppMode property
  489. */
  490. function getAppMode()
  491. {
  492. return $this->_props['AppMode'];
  493. }
  494. /**
  495. * Read accessor of PageSize.
  496. *
  497. * @access public
  498. * @return number Value of the PageSize property
  499. */
  500. function getPageSize()
  501. {
  502. return $this->_props['PageSize'];
  503. }
  504. /**
  505. * Write accessor of PageSize.
  506. *
  507. * @access public
  508. * @param number $value The new value for the PageSize property
  509. * @return void
  510. */
  511. function setPageSize($value)
  512. {
  513. $this->_props['PageSize'] = $value;
  514. }
  515. /**
  516. * Read accessor of ProxyServer.
  517. * ProxyServer to pass down to cURL (CURLOPT_PROXY)
  518. * pass as a string in format "host:port"
  519. *
  520. * @access public
  521. * @return string Value of the ProxyServer property
  522. */
  523. function getProxyServer()
  524. {
  525. return $this->_props['ProxyServer'];
  526. }
  527. /**
  528. * Write accessor of ProxyServer.
  529. * ProxyServer to pass down to cURL (CURLOPT_PROXY)
  530. * pass as a string in format "host:port"
  531. *
  532. * @access public
  533. * @param string $value The new value for the ProxyServer property
  534. * @return void
  535. */
  536. function setProxyServer($value)
  537. {
  538. $this->_props['ProxyServer'] = $value;
  539. }
  540. /**
  541. * Read accessor of ProxyUidPwd.
  542. * ProxyServer to pass down to cURL (CURLOPT_PROXYUSERPWD)
  543. * use "name:password" as a string divided by colon
  544. *
  545. * @access public
  546. * @return string Value of the ProxyUidPwd property
  547. */
  548. function getProxyUidPwd()
  549. {
  550. return $this->_props['ProxyUidPwd'];
  551. }
  552. /**
  553. * Write accessor of ProxyUidPwd.
  554. * ProxyServer to pass down to cURL (CURLOPT_PROXYUSERPWD)
  555. * use "name:password" as a string divided by colon
  556. *
  557. * @access public
  558. * @param string $value The new value for the ProxyUidPwd property
  559. * @return void
  560. */
  561. function setProxyUidPwd($value)
  562. {
  563. $this->_props['ProxyUidPwd'] = $value;
  564. }
  565. /**
  566. * Read accessor of ProxyServerType.
  567. * ProxyServer Type to pass down to cURL
  568. * CURLOPT_PROXYTYPE (101)
  569. * CURLPROXY_HTTP = 0,
  570. * CURLPROXY_SOCKS4 = 4,
  571. * CURLPROXY_SOCKS5 = 5
  572. * set to EBAY_NOTHING if you are using direct access (default). The cURL operation will acutally check against this value and then use the more abritrate values ProxyXXX
  573. *
  574. * @access public
  575. * @return number Value of the ProxyServerType property
  576. */
  577. function getProxyServerType()
  578. {
  579. return $this->_props['ProxyServerType'];
  580. }
  581. /**
  582. * Write accessor of ProxyServerType.
  583. * ProxyServer Type to pass down to cURL
  584. * CURLOPT_PROXYTYPE (101)
  585. * CURLPROXY_HTTP = 0,
  586. * CURLPROXY_SOCKS4 = 4,
  587. * CURLPROXY_SOCKS5 = 5
  588. * set to EBAY_NOTHING if you are using direct access (default). The cURL operation will acutally check against this value and then use the more abritrate values ProxyXXX
  589. *
  590. * @access public
  591. * @param number $value The new value for the ProxyServerType property
  592. * @return void
  593. */
  594. function setProxyServerType($value)
  595. {
  596. $this->_props['ProxyServerType'] = $value;
  597. }
  598. /**
  599. * Read accessor of UseHttpCompression.
  600. * flag to switch to gzip-encoding for the request. default is true which should be suitable for most situation. If using a very fast internet connection with low data amounts to retrieve might be more efficient to switch the compression of.
  601. * You will a suitable cURL extension for using this
  602. *
  603. * @access public
  604. * @return boolean Value of the UseHttpCompression property
  605. */
  606. function getUseHttpCompression()
  607. {
  608. return $this->_props['UseHttpCompression'];
  609. }
  610. /**
  611. * Write accessor of UseHttpCompression.
  612. * flag to switch to gzip-encoding for the request. default is true which should be suitable for most situation. If using a very fast internet connection with low data amounts to retrieve might be more efficient to switch the compression of.
  613. * You will a suitable cURL extension for using this
  614. *
  615. * @access public
  616. * @param boolean $value The new value for the UseHttpCompression property
  617. * @return void
  618. */
  619. function setUseHttpCompression($value)
  620. {
  621. $this->_props['UseHttpCompression'] = $value;
  622. }
  623. /**
  624. *
  625. * @access private
  626. * @var array
  627. */
  628. var $_keys = array();
  629. /**
  630. * flag to switch to gzip-encoding for the request. default is true which should be suitable for most situation. If using a very fast internet connection with low data amounts to retrieve might be more efficient to switch the compression of.
  631. * You will a suitable cURL extension for using this
  632. *
  633. * @access private
  634. * @var array
  635. */
  636. var $_debugSwitches = array();
  637. /**
  638. * Read accessor of SerializeFolder.
  639. * specifies a folder name for (de)serialization. Take care of any security issue on the folder (R/W for the www user or IUSR_xxx on IIS)
  640. *
  641. * @access public
  642. * @return string Value of the SerializeFolder property
  643. */
  644. function getSerializeFolder()
  645. {
  646. return $this->_props['SerializeFolder'];
  647. }
  648. /**
  649. * Write accessor of SerializeFolder.
  650. * specifies a folder name for (de)serialization. Take care of any security issue on the folder (R/W for the www user or IUSR_xxx on IIS)
  651. *
  652. * @access public
  653. * @param string $value The new value for the SerializeFolder property
  654. * @return void
  655. */
  656. function setSerializeFolder($value)
  657. {
  658. $this->_props['SerializeFolder'] = $value;
  659. }
  660. /**
  661. * Read accessor of XmlEncoding.
  662. * use 0 for UTF-8 encoding (default)
  663. * as with compat-level 401 no other values are allowed
  664. *
  665. * @access public
  666. * @return number Value of the XmlEncoding property
  667. */
  668. function getXmlEncoding()
  669. {
  670. return $this->_props['XmlEncoding'];
  671. }
  672. /**
  673. * Write accessor of XmlEncoding.
  674. * use 0 for UTF-8 encoding (default)
  675. * as with compat-level 401 no other values are allowed
  676. *
  677. * @access public
  678. * @param number $value The new value for the XmlEncoding property
  679. * @return void
  680. */
  681. function setXmlEncoding($value)
  682. {
  683. $this->_props['XmlEncoding'] = $value;
  684. }
  685. /**
  686. * Read accessor of DoXmlUtf8Decoding.
  687. * set this flag will result in decode all incoming data to iso-8859-1 using php utf8_decode.
  688. *
  689. * @access public
  690. * @return boolean Value of the DoXmlUtf8Decoding property
  691. */
  692. function getDoXmlUtf8Decoding()
  693. {
  694. return $this->_props['DoXmlUtf8Decoding'];
  695. }
  696. /**
  697. * Write accessor of DoXmlUtf8Decoding.
  698. * set this flag will result in decode all incoming data to iso-8859-1 using php utf8_decode.
  699. *
  700. * @access public
  701. * @param boolean $value The new value for the DoXmlUtf8Decoding property
  702. * @return void
  703. */
  704. function setDoXmlUtf8Decoding($value)
  705. {
  706. $this->_props['DoXmlUtf8Decoding'] = $value;
  707. }
  708. /**
  709. * Read accessor of DoXmlUtf8Encoding.
  710. * set this flag will result in encode all outgoing data to uft-8 assuming the data set to the objects are in iso-8859-1 characterset.
  711. *
  712. * @access public
  713. * @return boolean Value of the DoXmlUtf8Encoding property
  714. */
  715. function getDoXmlUtf8Encoding()
  716. {
  717. return $this->_props['DoXmlUtf8Encoding'];
  718. }
  719. /**
  720. * Write accessor of DoXmlUtf8Encoding.
  721. * set this flag will result in encode all outgoing data to uft-8 assuming the data set to the objects are in iso-8859-1 characterset.
  722. *
  723. * @access public
  724. * @param boolean $value The new value for the DoXmlUtf8Encoding property
  725. * @return void
  726. */
  727. function setDoXmlUtf8Encoding($value)
  728. {
  729. $this->_props['DoXmlUtf8Encoding'] = $value;
  730. }
  731. /**
  732. * Read accessor of RawLogMode.
  733. * Set to true to turn raw log-mode on
  734. *
  735. * @access public
  736. * @return boolean Value of the RawLogMode property
  737. */
  738. function getRawLogMode()
  739. {
  740. return $this->_props['RawLogMode'];
  741. }
  742. /**
  743. * Write accessor of RawLogMode.
  744. * Set to true to turn raw log-mode on
  745. *
  746. * @access public
  747. * @param boolean $value The new value for the RawLogMode property
  748. * @return void
  749. */
  750. function setRawLogMode($value)
  751. {
  752. $this->_props['RawLogMode'] = $value;
  753. }
  754. /**
  755. * Read accessor of RawLogPath.
  756. * Path where to place RawLogged Files
  757. *
  758. * @access public
  759. * @return string Value of the RawLogPath property
  760. */
  761. function getRawLogPath()
  762. {
  763. return $this->_props['RawLogPath'];
  764. }
  765. /**
  766. * Write accessor of RawLogPath.
  767. * Path where to place RawLogged Files
  768. *
  769. * @access public
  770. * @param string $value The new value for the RawLogPath property
  771. * @return void
  772. */
  773. function setRawLogPath($value)
  774. {
  775. $this->_props['RawLogPath'] = $value;
  776. }
  777. /**
  778. * Read accessor of RawLogSeq.
  779. * Seq No for paginated results within a Raw Logging Session, will be incremented after a log is written
  780. *
  781. * @access public
  782. * @return number Value of the RawLogSeq property
  783. */
  784. function getRawLogSeq()
  785. {
  786. return $this->_props['RawLogSeq'];
  787. }
  788. /**
  789. * Write accessor of RawLogSeq.
  790. * Seq No for paginated results within a Raw Logging Session, will be incremented after a log is written
  791. *
  792. * @access public
  793. * @param number $value The new value for the RawLogSeq property
  794. * @return void
  795. */
  796. function setRawLogSeq($value)
  797. {
  798. $this->_props['RawLogSeq'] = $value;
  799. }
  800. /**
  801. * Read accessor of RawLogName.
  802. * Name of the file to write in RawLogMode, if not given the API methodname is used.
  803. * The resulting filename is RawLogPath + "/" + RawLogName + "_" + RawLogSeq + ".xml"
  804. *
  805. * @access public
  806. * @return string Value of the RawLogName property
  807. */
  808. function getRawLogName()
  809. {
  810. return $this->_props['RawLogName'];
  811. }
  812. /**
  813. * Write accessor of RawLogName.
  814. * Name of the file to write in RawLogMode, if not given the API methodname is used.
  815. * The resulting filename is RawLogPath + "/" + RawLogName + "_" + RawLogSeq + ".xml"
  816. *
  817. * @access public
  818. * @param string $value The new value for the RawLogName property
  819. * @return void
  820. */
  821. function setRawLogName($value)
  822. {
  823. $this->_props['RawLogName'] = $value;
  824. }
  825. /**
  826. *
  827. * @access private
  828. * @var Ebay _CryptoProvider
  829. */
  830. var $_CryptoProvider = null;
  831. /**
  832. * Standard init function, should be called from the constructor(s)
  833. */
  834. function _init()
  835. {
  836. $this->_props['AppId'] = EBAY_NOTHING;
  837. $this->_props['DevId'] = EBAY_NOTHING;
  838. $this->_props['CertId'] = EBAY_NOTHING;
  839. $this->_props['RequestPassword'] = EBAY_NOTHING;
  840. $this->_props['RequestUser'] = EBAY_NOTHING;
  841. $this->_props['TimeOffset'] = EBAY_NOTHING;
  842. $this->_props['LogLevel'] = EBAY_NOTHING;
  843. $this->_props['LogFilename'] = EBAY_NOTHING;
  844. $this->_props['LogMode'] = 0;
  845. $this->_props['ApiMode'] = EBAY_NOTHING;
  846. $this->_props['SiteId'] = EBAY_NOTHING;
  847. $this->_props['CompatibilityLevel'] = EBAY_NOTHING;
  848. $this->_props['ErrorLevel'] = EBAY_NOTHING;
  849. $this->_props['ErrorLanguage'] = 0;
  850. $this->_props['RequestTimeout'] = EBAY_NOTHING;
  851. $this->_props['TokenMode'] = false;
  852. $this->_props['TokenPickupFile'] = EBAY_NOTHING;
  853. $this->_props['TokenUsePickupFile'] = false;
  854. $this->_props['ApiUrl'] = EBAY_NOTHING;
  855. $this->_props['AppMode'] = EBAY_NOTHING;
  856. $this->_props['PageSize'] = 200;
  857. $this->_props['ProxyServer'] = EBAY_NOTHING;
  858. $this->_props['ProxyUidPwd'] = EBAY_NOTHING;
  859. $this->_props['ProxyServerType'] = EBAY_NOTHING;
  860. $this->_props['UseHttpCompression'] = false;
  861. $this->_props['SerializeFolder'] = null;
  862. $this->_props['XmlEncoding'] = 0;
  863. $this->_props['DoXmlUtf8Decoding'] = false;
  864. $this->_props['DoXmlUtf8Encoding'] = false;
  865. $this->_props['RawLogMode'] = false;
  866. $this->_props['RawLogPath'] = EBAY_NOTHING;
  867. $this->_props['RawLogSeq'] = 1;
  868. $this->_props['RawLogName'] = EBAY_NOTHING;
  869. }
  870. /**
  871. *
  872. * @access public
  873. * @param string $configFile Path to a config-file (ini-style) to read main config parameters from.
  874. * @return boolean
  875. */
  876. function InitFromConfig($configFile)
  877. {
  878. $cfg = parse_ini_file($configFile);
  879. if ($cfg == false) {
  880. $this->LogMsg("config file not found", 0, E_ERROR);
  881. }
  882. $this->_keys['test'] = array($cfg['app-key-test'], $cfg['dev-key-test'], $cfg['cert-id-test']);
  883. $this->_keys['prod'] = array($cfg['app-key-prod'], $cfg['dev-key-prod'], $cfg['cert-id-prod']);
  884. if (isset($cfg['site-id']))
  885. $this->setSiteId($cfg['site-id']);
  886. if (isset($cfg['user']))
  887. $this->setRequestUser($cfg['user']);
  888. if (isset($cfg['password']))
  889. $this->setRequestPassword($cfg['password']);
  890. if (isset($cfg['app-mode']))
  891. $this->setAppMode($cfg['app-mode']);
  892. if (isset($cfg['api-mode']))
  893. $this->setApiMode($cfg['api-mode']);
  894. if (isset($cfg['compat-level']))
  895. $this->setCompatibilityLevel($cfg['compat-level']);
  896. if (isset($cfg['error-level']))
  897. $this->setErrorLevel($cfg['error-level']);
  898. if (isset($cfg['request-timeout']))
  899. $this->setRequestTimeout($cfg['request-timeout']);
  900. if (isset($cfg['serialize-folder']))
  901. $this->setSerializeFolder($cfg['serialize-folder']);
  902. if (isset($cfg['token-mode'])) {
  903. $this->setTokenMode($cfg['token-mode']);
  904. if (isset($cfg['token-pickup-file'])) {
  905. $this->setTokenPickupFile(EBAY_DATA_FOLDER.$cfg['token-pickup-file']);
  906. // $this->setTokenPickupFile($cfg['token-pickup-file']);
  907. $this->setTokenUsePickupFile(true);
  908. }
  909. }
  910. // only utf-8 encoding is allowed !!!
  911. $this->setXmlEncoding(0);
  912. if (isset($cfg['error-language'])) {
  913. $this->setErrorLanguage($cfg['error-language']);
  914. }else {
  915. $this->setErrorLanguage(0);
  916. }
  917. if (isset($cfg['xml-extra-decode'])) {
  918. $this->setDoXmlUtf8Decoding($cfg['xml-extra-decode']);
  919. }else {
  920. $this->setDoXmlUtf8Decoding(0);
  921. }
  922. if (isset($cfg['xml-extra-encode'])) {
  923. $this->setDoXmlUtf8Encoding($cfg['xml-extra-encode']);
  924. }else {
  925. $this->setDoXmlUtf8Encoding(0);
  926. }
  927. if (isset($cfg['use-http-compression'])) {
  928. $this->setUseHttpCompression($cfg['use-http-compression']);
  929. }
  930. if (isset($cfg['log-file'])) {
  931. $this->setLogFilename($cfg['log-file']);
  932. }
  933. if (isset($cfg['log-level'])) {
  934. $this->setLogLevel($cfg['log-level']);
  935. }
  936. if (isset($cfg['log-mode'])) {
  937. $this->setLogMode($cfg['log-mode']);
  938. }
  939. if (isset($cfg['debug-showin'])) {
  940. $this->setDebugSwitch('showin');
  941. }
  942. if (isset($cfg['debug-showout'])) {
  943. $this->setDebugSwitch('showout');
  944. }
  945. if (isset($cfg['debug-profiling'])) {
  946. $this->setDebugSwitch('profiling');
  947. }
  948. if (isset($cfg['debug-curl-verbose'])) {
  949. $this->setDebugSwitch('curl-verbose');
  950. }
  951. if (isset($cfg['raw-log-mode'])) {
  952. $this->setRawLogMode($cfg['raw-log-mode']);
  953. }
  954. if (isset($cfg['raw-log-path'])) {
  955. $this->setRawLogPath($cfg['raw-log-path']);
  956. }
  957. if (isset($cfg['raw-log-name'])) {
  958. $this->setRawLogName($cfg['raw-log-name']);
  959. }
  960. if (isset($cfg['raw-log-seq'])) {
  961. $this->setRawLogSeq($cfg['raw-log-seq']);
  962. }
  963. if (isset($cfg['max-transactions-per-page'])) {
  964. $this->_props['PageSize'] = $cfg['max-transactions-per-page'];
  965. if ($this->_props['PageSize'] <= 0)
  966. $this->_props['PageSize'] = 200;
  967. }
  968. if (isset($cfg['use_standard_logger'])) {
  969. $this->setUseStandardLogger($cfg['use_standard_logger']);
  970. }
  971. }
  972. /**
  973. * Writes a log-message to the logFile
  974. *
  975. * @access public
  976. * @param string $msg
  977. * @param number $errNo
  978. * @param number $severity
  979. * @return void
  980. */
  981. function LogMsg($msg, $errNo, $severity)
  982. {
  983. $dt = date("Y-m-d H:i:s (T)");
  984. $errStr = "$dt,#$errNo,$severity,$msg\r\n";
  985. $destination = $this->getLogFilename();
  986. switch ($this->getLogMode()) {
  987. case 0:
  988. error_log($errStr, 0);
  989. break;
  990. case 1:
  991. // TODO
  992. // assume the logfile name as an email address
  993. error_log($errStr, 1, $destination);
  994. break;
  995. case 2:
  996. // TODO
  997. // assume the logfile name as the debugger port
  998. error_log($errStr, 2, $destination);
  999. break;
  1000. case 3:
  1001. error_log($errStr, 3, $destination);
  1002. break;
  1003. } // switch
  1004. // TODO
  1005. // maybe die here on fatal errors
  1006. }
  1007. /**
  1008. * special processing needed for AppMode
  1009. *
  1010. * @access public
  1011. * @param define $value
  1012. * @return void
  1013. */
  1014. function setAppMode($value)
  1015. {
  1016. $this->_props['AppMode'] = $value;
  1017. // setting the URL for the API
  1018. // recording to the AppMode selected
  1019. switch ($value) {
  1020. case 0:
  1021. $this->_setProp('ApiUrl', 'https://api.ebay.com/wsapi');
  1022. $this->_setProp('AppId', $this->_keys['prod'][0]);
  1023. $this->_setProp('DevId', $this->_keys['prod'][1]);
  1024. $this->_setProp('CertId', $this->_keys['prod'][2]);
  1025. break;
  1026. case 1:
  1027. $this->_setProp('ApiUrl', 'https://api.sandbox.ebay.com/wsapi');
  1028. $this->_setProp('AppId', $this->_keys['test'][0]);
  1029. $this->_setProp('DevId', $this->_keys['test'][1]);
  1030. $this->_setProp('CertId', $this->_keys['test'][2]);
  1031. break;
  1032. case 2:
  1033. $this->_setProp('ApiUrl', 'https://api.ebay.com/wsapi');
  1034. $this->_setProp('AppId', $this->_keys['test'][0]);
  1035. $this->_setProp('DevId', $this->_keys['test'][1]);
  1036. $this->_setProp('CertId', $this->_keys['test'][2]);
  1037. break;
  1038. }
  1039. }
  1040. /**
  1041. *
  1042. * @access public
  1043. * @param string $configFile
  1044. * @return void
  1045. */
  1046. function EbatNs_Session($configFile = null)
  1047. {
  1048. // call to initialisation
  1049. // (be sure to call this always on the actual class and prevent any overwriting)
  1050. EbatNs_Session::_init();
  1051. $this->_props['RequestToken'] = EBAY_NOTHING;
  1052. if ($configFile != null) {
  1053. $this->InitFromConfig($configFile);
  1054. }
  1055. }
  1056. /**
  1057. * sets various internal debug switches
  1058. *
  1059. * @access public
  1060. * @param string $switch use one the following switches (string)
  1061. * 'showin' prints raw input (headers, xml)
  1062. * 'showout' print raw output (xml)
  1063. * 'logout' saves all ouput to a log-file with lays under /var/tmp with the name of the API-call and .log
  1064. * 'pickoutlog' instead of making the call the log-file from 'logout' is picked up. Attention not suitable for paginated results.
  1065. * 'profile' logs profiling information for any API-logs
  1066. * @param boolean $onoff
  1067. * @return void
  1068. */
  1069. function setDebugSwitch($switch, $onoff = true)
  1070. {
  1071. if ($onoff == true) {
  1072. $this->_debugSwitches["$switch"] = true;
  1073. }else {
  1074. unset($this->_debugSwitches["$switch"]);
  1075. }
  1076. }
  1077. /**
  1078. * reads the content of the TokenFile to the Attribute RequestToken. If you are running in TokenMode the TokenFile and the Flag 'TokenUsePickupFile' is true the fill will be read whenever a call this made.
  1079. *
  1080. * @access public
  1081. * @return void
  1082. */
  1083. function ReadTokenFile()
  1084. {
  1085. if ($this->getTokenUsePickupFile()) {
  1086. $fname = $this->getTokenPickupFile();
  1087. $fh = fopen($fname, "r");
  1088. $this->_props['RequestToken'] = trim(fread($fh, filesize($fname)));
  1089. fclose($fh);
  1090. }
  1091. }
  1092. /**
  1093. * Writes the content of the Attribute RequestToken to the TokenFile. If the ApiCaller detects a RefreshToken after a call the new token will get automatically writen to the file.
  1094. *
  1095. * @access public
  1096. * @return void
  1097. */
  1098. function WriteTokenFile()
  1099. {
  1100. if ($this->getTokenUsePickupFile()) {
  1101. $fname = $this->getTokenPickupFile();
  1102. $fh = fopen($fname, "w+");
  1103. fwrite($fh, $this->_props['RequestToken']);
  1104. fclose($fh);
  1105. }
  1106. }
  1107. /**
  1108. *
  1109. * @access public
  1110. * @param $ <unspecified> $data
  1111. * @return void
  1112. */
  1113. function EncyrptData($data)
  1114. {
  1115. if ($this->_CryptoProvider != null)
  1116. return $this->_CryptoProvider->Encrypt($data);
  1117. else
  1118. return $data;
  1119. }
  1120. /**
  1121. *
  1122. * @access public
  1123. * @param $ <unspecified> $data
  1124. * @return void
  1125. */
  1126. function DecyrptData($data)
  1127. {
  1128. if ($this->_CryptoProvider != null)
  1129. return $this->_CryptoProvider->Decrypt($data);
  1130. else
  1131. return $data;
  1132. }
  1133. /**
  1134. *
  1135. * @access public
  1136. * @param Ebay $ _CryptoProvider $provider
  1137. * @return void
  1138. */
  1139. function setCryptoProvider($provider)
  1140. {
  1141. $this->_CryptoProvider = $provider;
  1142. }
  1143. /**
  1144. *
  1145. * @access public
  1146. * @return void
  1147. */
  1148. function getRequestToken()
  1149. {
  1150. return $this->DecyrptData($this->_props['RequestToken']);
  1151. }
  1152. /**
  1153. *
  1154. * @access public
  1155. * @param string $value
  1156. * @return void
  1157. */
  1158. function setRequestToken($value)
  1159. {
  1160. $this->_props['RequestToken'] = $this->EncyrptData($value);
  1161. }
  1162. /**
  1163. *
  1164. * @access public
  1165. * @param string $value
  1166. * @return void
  1167. */
  1168. function setUseStandardLogger($value)
  1169. {
  1170. $this->_props['UseStandardLogger'] = $value;
  1171. }
  1172. /**
  1173. *
  1174. * @access public
  1175. * @return void
  1176. */
  1177. function getUseStandardLogger()
  1178. {
  1179. return ($this->_props['UseStandardLogger'] ? true : false);
  1180. }
  1181. }
  1182. ?>