<?PHP

/**
 * Sample code demonstrating how to call/use the omNovia OneTime Password API
 *
 * Tested with PHP 4.4.0
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESSED OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @category   Web Services
 * @author     Matthew Boehm <mboehm@omnovia.com>
 * @copyright  2006 Matthew Boehm, omNovia Technologies
 * @version    1.0
 * @link       http://pear.php.net/package/XML_RPC
**/

/**
 * NOTE: All RPC commands require 'company ID' and 'company password'.
 * Both of these are supplied to you by omNovia Support.
**/

/**
 * The PEAR package, XML_RPC, is required to be installed.
 * Visit the @link in the header comments for install procedures.
**/
require_once 'XML/RPC.php';

/**
 * All 'commands' are called by constructing an array of
 * XML_RPC_Value elements. Depending on which RPC you are
 * calling, different numbers of elements (aka parameters)
 * are needed.
 *
**/

/* Sample Parameters for adding a user. addUser is the most complex as there are
 * many options for creating a user, but most are self-explanatory.
**/
$new_token = array(
        new 
XML_RPC_Value(2"int"),                    // unique ID from omnovia
        
new XML_RPC_Value("1235""string"),                // company password
        
new XML_RPC_Value(3"int"),                    // roomID
        
new XML_RPC_Value(2"int"),                    // movie level to show. will display this level and below.
        
new XML_RPC_Value(5"int"),                    // number of allowed views (use 0 for unlimited)
        
new XML_RPC_Value(0"int"),                    // whether to show remaining views to attendees
        
new XML_RPC_Value("2006-10-01 12:00""string"),        // start date/time (24hr mode)
        
new XML_RPC_Value("2006-10-05 13:00""string")            // expiration date/time (24hr mode)
);

/* Sample Parameters for deleting, resetting or disabling a user.
 * NOTE: Resetting, Deleting and Disabling a user all take the same
 * 3 parameters.
 */
$delete_token = array(
        new 
XML_RPC_Value(2"int"),                    // company id omnovia
        
new XML_RPC_Value("1235""string"),                // company password
        
new XML_RPC_Value(3"int"),                    // roomID of token
        
new XML_RPC_Value("9204145460""string")            // token to delete
);

//$msg = new XML_RPC_Message('otp.create', $new_token);            // Can only call one function at a time
$msg = new XML_RPC_Message('otp.delete'$delete_token);

/*
 * The XML_RPC URL is https://www.omnovia.com/members/onetimerpc.php
 */

/* This will create a new client object. */
$client = new XML_RPC_Client('/members/onetimerpc.php''https://www.omnovia.com');

/* For production environment, turn off debugging. */
$client->setDebug(0);

/* Send the command and get back the resultant message (return value) */
$resp $client->send($msg5);

/* If there was no return value, most likely the call didn't happen
 * due to various internet issues.
 */
if(!$resp)
{
    echo 
'Communication error: ' $client->errstr;
    exit();
}

/* If a fault code was returned, this means omNovia received our request,
 * processed it, and an error was generated. Print out the error value
 * and the error message.
 *
 * If no fault code was returned, parse out the returned result and display
 * or handle the result in your code.
 */
if(!$resp->faultCode())
{
    
$val $resp->value();
    
$data XML_RPC_decode($val);
    print 
$data;
}
else
{
    echo 
'Fault Code: ' $resp->faultCode() . "\n";
    echo 
'Fault Reason: ' $resp->faultString() . "\n";
}

?>