Bez popisu

main.php 898B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. require_once 'sdk_resolver.php';
  3. if (!function_exists('analyst_init')) {
  4. /**
  5. * Initialize analyst
  6. *
  7. * @param array $options
  8. */
  9. function analyst_init ($options) {
  10. // Try resolve latest supported SDK
  11. // In case resolving is failed exit the execution
  12. try {
  13. analyst_resolve_sdk($options['base-dir']);
  14. } catch (Exception $exception) {
  15. error_log('[ANALYST] Cannot resolve any supported SDK');
  16. return;
  17. }
  18. try {
  19. global /** @var Analyst\Analyst $analyst */
  20. $analyst;
  21. // Set global instance of analyst
  22. if (!$analyst) {
  23. $analyst = Analyst\Analyst::getInstance();
  24. }
  25. $analyst->registerAccount(new Account\Account($options['client-id'], $options['client-secret'], $options['base-dir']));
  26. } catch (Exception $e) {
  27. error_log('Analyst SDK receive an error: [' . $e->getMessage() . '] Please contact our support at support@analyst.com');
  28. }
  29. }
  30. }