<?php

/*
 *  File:			simple.php
 *  Description:	Simple SDK web/command line example
 *  Author:			Nicholas Robinson 11/26/2011
 */
# Include BoxeeBoxPHPRCI class
require_once '../BoxeeBoxPHPRCI.class.php';
# Connect to BoxeeBox
$bbphprci = new BoxeeBoxPHPRCI('boxeebox');
# Set Volume
echo 'Changing Volume to 75:' . $bbphprci->SetVolume(75) . '<br />';
<?php

/*
 *  File:			simplediscovery.php
 *  Description:	Simple SDK web/command line example with automatic discovery
 *  Author:			Nicholas Robinson 11/26/2011
 */
# Include BoxeeBoxPHPRCI class
require_once '../BoxeeBoxPHPRCI.class.php';
# Initialize BBPHPRCI SDK
$bbphprci = new BoxeeBoxPHPRCI();
# Attempt automatic discovery
$discovered = $bbphprci->discover();
# If a BoxeeBox is dicovered
if ($discovered) {
    # Extract address and port for display
    list($serverAddress, $serverPort) = $discovered;
    # Output discovery results
    echo 'Discovered ' . $serverAddress . ':' . $serverPort . "\n";
    # Set Volume to 75
    echo 'Changing Volume to 75:' . $bbphprci->SetVolume(75) . "\n";
} else {
    echo 'Discovery FAILED';
}
<?php

/*
 *  File:			simpleparse.php
 *  Description:	Simple SDK web/command line example with parsing
 *  Author:			Nicholas Robinson 11/26/2011
 */
# Define volume chage
define('DV', -10);
# Include BoxeeBoxPHPRCI class
require_once '../BoxeeBoxPHPRCI.class.php';
# Connect to BoxeeBox
$bbphprci = new BoxeeBoxPHPRCI('boxeebox');
# Get raw starting volume output
$rawResult = $bbphprci->getVolume();
# Parse for starting volume percentage
preg_match('/\\<html\\>\\n<li\\>(.*)\\<\\/html\\>/', $rawResult, $matches);
$startingVolume = (int) $matches[1];
# Output starting volume
echo 'Starting Volume: ' . $startingVolume . '<br />';
# Change volume by DV
echo 'Changing Volume by ' . DV . ':' . $bbphprci->SetVolume($startingVolume + DV) . '<br />';
# Verify new volume
echo 'New Volume:' . $bbphprci->getVolume() . '<br />';