soap.test.php 2.1 KB

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