|
AddUserPhp
Show how to create an user using the library
The following code shows hoe to create a OpenSimulator user using the library <?php
// Load metaverse manager
require_once '../../../src/mjs/mmetaverse/manager/MMetaverse.class.php';
require_once '../../../src/mjs/mmetaverse/types/MUUID.class.php';
try {
// Try to create the manager with
// the configuration file specified
$configFile = 'mmetaverse_conf.xml';
$mmetaverse = new MMetaverse($configFile);
// Create a user
$uuid = MUUID::random();
$firstName = 'New';
$lastName = 'User';
$user = new MUser($uuid,$firstName,$lastName);
$user->setPassword('12345');
// Create the user using the user manager
$mmetaverse->getUserManager()->createUser($user);
// Show message
echo 'User created';
} catch (Exception $e) {
// Show the error information
echo 'Error : ' . $e->getMessage();
}
?>Configuration File (mmetaverse_conf.xml) : <?xml version="1.0" encoding="UTF-8"?>
<!-- MMetaverse Configuration -->
<config>
<!-- OpenSim -->
<opensim>
<!-- Absolute path of the opensimulator -->
<path>/home/marlonj/tmp/opensim/bin</path>
<!-- Database engine -->
<databaseEngine>sqlite</databaseEngine>
</opensim>
</config>
|
► Sign in to add a comment