예제 #1
0
 /**
  * @param string|array $responseHeader
  */
 public function setResponseHeader($responseHeader)
 {
     if (is_string($responseHeader)) {
         require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Utils' . DIRECTORY_SEPARATOR . 'HttpParseHeaders.php';
         $responseHeader = http_parse_headers($responseHeader);
     }
     if (isset($responseHeader['ClientId'])) {
         $this->smartHome->setClientId($responseHeader['ClientId']);
     }
     $this->responseHeader = $responseHeader;
 }
예제 #2
0
 * Date: 07.12.13
 * Time: 15:44
 */
use Bubelbub\SmartHomePHP\SmartHome;
use Bubelbub\SmartHomePHP\Entity\LogicalDevice;
require_once 'vendor/autoload.php';
$newLine = php_sapi_name() == 'cli' ? PHP_EOL : '<br />';
$config = new SimpleXMLElement('<SmartHomeConfiguration />');
$configFile = __FILE__ . '.config';
if (file_exists($configFile)) {
    try {
        $config = new SimpleXMLElement($configFile, 0, true);
    } catch (Exception $ex) {
    }
}
$sh = new SmartHome('Hostname or IP address', 'Username', 'Password');
if (!file_exists($configFile)) {
    $config->addChild('SessionId', $sh->getSessionId());
    $config->addChild('ClientId', $sh->getClientId());
    $config->addChild('Version', $sh->getVersion());
    $config->addChild('ConfigurationVersion', $sh->getConfigVersion());
    $config->saveXML($configFile);
}
$sh->setSessionId((string) $config->SessionId);
$sh->setClientId((string) $config->ClientId);
$sh->setVersion((string) $config->Version);
$sh->setConfigVersion((string) $config->ConfigurationVersion);
// get your current session id
echo 'Your session id is ' . $sh->getSessionId() . $newLine;
// get your current session id
echo 'Your current client id is ' . $sh->getClientId() . $newLine;