client.php 968 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /* See license terms in /license.txt */
  3. /**
  4. * This is a script used to automatically import a list of users from
  5. * a CSV file into Dokeos.
  6. * It is triggered by a cron task configured on the server.
  7. *
  8. * @uses /main/webservices/user_import/
  9. *
  10. * @author Eric Marguin <eric.marguin@dokeos.com>
  11. *
  12. * @package chamilo.cron
  13. */
  14. /**
  15. * Global cycle: init, execute, output.
  16. */
  17. require_once __DIR__.'/../../inc/global.inc.php';
  18. // check if this client has been called by php_cli (command line or cron)
  19. if (php_sapi_name() != 'cli') {
  20. echo 'You can\'t call this service through a browser';
  21. die();
  22. }
  23. // create client
  24. $client = new nusoap_client(api_get_path(WEB_CODE_PATH).'cron/user_import/service.php');
  25. // call import_user method
  26. $response = $client->call(
  27. 'import_users',
  28. [
  29. 'filepath' => api_get_path(SYS_UPLOAD_PATH)."users_import.csv",
  30. 'security_key' => api_get_configuration_value('security_key'),
  31. ]
  32. );
  33. echo $response;