KerioConnectApi.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * This file is part of the kerio-api-php.
  4. *
  5. * Copyright (c) Kerio Technologies s.r.o.
  6. *
  7. * For the full copyright and license information, please view
  8. * the file license.txt that was distributed with this source code
  9. * or visit Developer Zone. (http://www.kerio.com/developers)
  10. *
  11. * Do not modify this source code.
  12. * Any changes may be overwritten by a new version.
  13. */
  14. require_once(dirname(__FILE__) . '/class/KerioApi.php');
  15. /**
  16. * Administration API for Kerio Connect.
  17. *
  18. * This class implements product-specific methods and properties.
  19. *
  20. * Example:
  21. * <code>
  22. * <?php
  23. * require_once(dirname(__FILE__) . '/src/KerioConnectApi.php');
  24. *
  25. * $api = new KerioConnectApi('Sample application', 'Company Ltd.', '1.0');
  26. *
  27. * try {
  28. * $api->login('mail.company.tld', 'admin', 'SecretPassword');
  29. * $api->sendRequest('...');
  30. * $api->logout();
  31. * } catch (KerioApiException $error) {
  32. * print $error->getMessage();
  33. * }
  34. * ?>
  35. * </code>
  36. *
  37. * @copyright Copyright &copy; 2012-2012 Kerio Technologies s.r.o.
  38. * @license http://www.kerio.com/developers/license/sdk-agreement
  39. * @version 1.4.0.234
  40. */
  41. class KerioConnectApi extends KerioApi {
  42. /**
  43. * Defines default product-specific JSON-RPC settings.
  44. * @var array
  45. */
  46. protected $jsonRpc = array(
  47. 'version' => '2.0',
  48. 'port' => 4040,
  49. 'api' => '/admin/api/jsonrpc/'
  50. );
  51. /**
  52. * Class constructor.
  53. *
  54. * @param string Application name
  55. * @param string Application vendor
  56. * @param string Application version
  57. * @return void
  58. * @throws KerioApiException
  59. */
  60. public function __construct($name, $vendor, $version) {
  61. parent::__construct($name, $vendor, $version);
  62. }
  63. /**
  64. * Set component Web Administration.
  65. *
  66. * @param void
  67. * @return void
  68. */
  69. public function setComponentAdmin() {
  70. $this->setJsonRpc('2.0', 4040, '/admin/api/jsonrpc/');
  71. }
  72. /**
  73. * Set component Client aka WebMail.
  74. *
  75. * @param void
  76. * @return void
  77. */
  78. public function setComponentClient() {
  79. $this->setJsonRpc('2.0', 443, '/webmail/api/jsonrpc/');
  80. }
  81. /**
  82. * Set component WebMail.
  83. *
  84. * @param void
  85. * @return void
  86. * @deprecated
  87. */
  88. public function setComponentWebmail() {
  89. trigger_error("Deprecated function setComponentMyphone(), use setComponentClient() instead", E_USER_NOTICE);
  90. $this->setComponentClient();
  91. }
  92. /**
  93. * Get constants defined by product.
  94. *
  95. * @param void
  96. * @return array Array of constants
  97. */
  98. public function getConstants() {
  99. $response = $this->sendRequest('Server.getNamedConstantList');
  100. $constantList = array();
  101. foreach ($response['constants'] as $index) {
  102. $constantList[$index['name']] = $index['value'];
  103. }
  104. return $constantList;
  105. }
  106. }