soap.test.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php /* For licensing terms, see /license.txt */
  2. /**
  3. * Test script for soap.php.
  4. *
  5. * @author Yannick Warnier <yannick.warnier@beeznest.com>
  6. *
  7. * @package chamilo.webservices
  8. */
  9. exit; //remove to enable
  10. // Include the necessary files, assuming this script is located in main/lp/ or something like that
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. global $_configuration;
  13. // First build the signature to use with the webservice. We assume
  14. // we are calling the webservice from the same server, so getting
  15. // the IP (part of the signature) can be done through $_SERVER['REMOTE_ADDR']
  16. $ip = trim($_SERVER['REMOTE_ADDR']);
  17. $signature = sha1($ip.$_configuration['security_key']);
  18. // Prepare the arguments to the webservice, based on the user ID (int), the course ID (int), the learnpath_id and the learnpath_item_id:
  19. $uid = 1; // set to your user ID
  20. $cid = 1; // set to your course ID
  21. $lpid = 1; // set to your learnpath ID
  22. $lpiid = 1; // set to your learnpath item ID
  23. // Build the server's SOAP script address
  24. $server = api_get_path(WEB_CODE_PATH).'webservices/registration.soap.php?wsdl';
  25. /**
  26. * Call the webservice.
  27. */
  28. // Init the SOAP connection
  29. $client = new SoapClient($server, ['cache_wsdl' => WSDL_CACHE_NONE]);
  30. // Call the function we want with the right params...
  31. try {
  32. $response = $client->{'WSSearchSession'}(['term' => 'a', 'extrafields' => [], 'secret_key' => $signature]);
  33. } catch (Exception $e) {
  34. error_log(print_r($e->getMessage(), 1));
  35. }
  36. //$response = $client->{'WSReport.GetLearnpathStatusSingleItem'}($signature, 'chamilo_user_id', $uid, 'chamilo_course_id', $cid, $lpid, $lpiid);
  37. //$response = $client->{'WSReport.GetLearnpathProgress'}($signature, 'chamilo_user_id', $uid, 'chamilo_course_id', $cid, $lpid);
  38. //$response = $client->{'WSReport.GetLearnpathHighestLessonLocation'}($signature, 'chamilo_user_id', $uid, 'chamilo_course_id', $cid, $lpid);
  39. // Print the output, or do whatever you like with it (it's the status for this item):
  40. echo '<pre>'.print_r($response, 1).'</pre>';
  41. // This should print "complete", "incomplete" or any other active status.