Create Registration (PHP 5)

PHP 5 Sample Code

This is sample PHP 5 code that creates a new registration, delivering one activity to one user.



<?php
// only show errors
error_reporting(E_ERROR | E_PARSE);

require_once('LmsService1.inc');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Creating assignment...</title>
</head>

<body>
<?php
$lmsBinding = new LmsService1('https://demo.firmwater.com/lms/webservices/lmsservice1.asmx?wsdl', true, true, true);

// authenticate and set endpoint address
print('<p>Calling Login method...');
try
{
$loginResult = $lmsBinding->Login('your-licensee-login-id', 'your-username', 'your-password');
print('done.</p><code>');
print_r($loginResult);
print('</code>');
}
catch (LmsService1_Exception $e)
{
print('</p><h2>ERROR:</h2>');
print('<code>' . $e->getMessage() . '</code>');
}

// create registration
if ($loginResult != null)
{
// create LMS registration object
print('<p>Creating registration object...');
$reg = new LmsRegistrationObject();
$reg->LicenseeId = 'licensee-login-id';
$reg->Description = 'Test Assignment';
$reg->Type = 'individualDelivery';
$reg->ItemsToRegister = array(new SelectListItemOfString('add', 'course-external-id-1'));
$reg->PersonFilter = array(new SelectListItemOfString('add', 'username-1'));
$reg->IsEnabled = true;
$reg->StudentsOnly = false;
$reg->HasPersonFilter = true;
$reg->HasLocationFilter = false;
$reg->HasDepartmentFilter = false;
$reg->HasJobTitleFilter = false;
$reg->HasMemberTypeFilter = false;
$reg->HasLanguageFilter = false;
print('done.</p><code>');
print_r($reg);
print('</code>');
// create or update assignment
$saveResult = null;
try
{
print('<p>Creating or updating assignment...');
$saveResult = $lmsBinding->CreateOrUpdate($reg);
print('done.</p><code>');
print_r($saveResult);
print('</code>');
}
catch (LmsService1_Exception $e)
{
print('</p><h2>ERROR:</h2>');
print('<code>' . $e->getMessage() . '</code>');
}
}
?>
</body>
</html>
ċ
LmsService1.inc
(15k)
Stefan Leyhane,
Aug 11, 2014, 12:10 PM