function getCalleeLink($fromHash, $toHash) { global $link; $fromHash = mysql_real_escape_string($fromHash); $toHash = mysql_real_escape_string($toHash); $callerName = getDisplayName($toHash); $userClient = new SoapClient(OM_SERVER_ADDRESS . '/services/UserService?wsdl'); $roomClient = new SoapClient(OM_SERVER_ADDRESS . '/services/RoomService?wsdl'); $session = $userClient->getSession(); $loginResult = $userClient->loginUser(array('SID' => $session->return->session_id, 'username' => OM_ADMIN_LOGIN, 'userpass' => OM_ADMIN_PASS)); if ($loginResult > 0) { //Successfully logged in, searching for a room, if its created $confs = $roomClient->getRooms(array('SID' => $session->return->session_id, 'start' => 0, 'max' => 100, 'orderby' => 'name', 'asc' => true))->return->result; $roomId = null; foreach ($confs as $value) { if ($value->name == $fromHash . $toHash) { //room exists, returning link to it $roomId = $value->rooms_id; } } if ($roomId == null) { //room doesn't exist, creating one and returning a link $addRoomResult = $roomClient->addRoomWithModeration(array('SID' => $session->return->session_id, 'name' => $fromHash . $toHash, 'roomtypes_id' => 1, 'comment' => 'Call room', 'numberOfPartizipants' => 2, 'ispublic' => true, 'appointment' => false, 'isDemoRoom' => false, 'demoTime' => 0, 'isModeratedRoom' => true))->return; if ($addRoomResult > 0) { $roomId = $addRoomResult; } else { dieWithMessage(METHOD_GETCALLEELINK, 'Failed to add a room'); } } $setUserObjectResult = $userClient->setUserObjectAndGenerateRoomHash(array('SID' => $session->return->session_id, 'username' => $callerName, 'firstname' => $callerName, 'lastname' => '', 'profilePictureUrl' => '', 'email' => '', 'externalUserId' => 0, 'externalUserType' => 'caller', 'room_id' => $roomId, 'becomeModeratorAsInt' => 0, 'showAudioVideoTestAsInt' => 2))->return; if ($setUserObjectResult != null) { showResult(METHOD_GETCALLEELINK, OM_SERVER_ADDRESS . '/openmeetings/main.lzx.swf8.swf?secureHash=' . $setUserObjectResult); } else { dieWithMessage(METHOD_GETCALLEELINK, "Setting user object failed"); } } else { dieWithMessage(METHOD_GETCALLEELINK, "Login failed"); } }