<?php /** * ---------------------------------------- * Practical - PHP LG SmartTV API * ---------------------------------------- * https://github.com/SteveWinfield/PHP-LG-SmartTV **/ session_start(); include 'smartTV.php'; /** * Create instance of TV * @param IP Address of TV * (optional) @param Port of TV (default is 8080) **/ $tv = new SmartTV('192.168.2.103'); // new SmartTV('192.168.2.103', 8080) /** * Check if session already created. * If so.. don't request a new one. **/ if (!isset($_SESSION['SESSION_ID'])) { /** * Set pairing key (if you don't know the pairing key * execute the method ..->displayPairingKey() and it will * be shown on your tv) * @param Key **/ $tv->setPairingKey(678887); // $tv->displayPairingKey(); /**
<?php /** * ---------------------------------------- * Example - PHP LG SmartTV API * ---------------------------------------- * https://github.com/SteveWinfield/PHP-LG-SmartTV **/ include 'smartTV.php'; /** * Create instance of TV * @param IP Address of TV * (optional) @param Port of TV (default is 8080) **/ $tv = new SmartTV('192.168.2.103'); // new SmartTV('192.168.2.103', 8080) /** * Set pairing key (if you don't know the pairing key * execute the method ..->displayPairingKey() and it will * be shown on your tv) * @param Key **/ $tv->setPairingKey(678887); // $tv->displayPairingKey(); /** * Authenticate to the tv * @except Login fails (wrong pairing key?) **/ try { $tv->authenticate(); } catch (Exception $e) {
<?php include 'PHP-LG-SmartTV/smartTV.php'; $tv = new SmartTV('192.168.0.11', 8080); $tv->setPairingKey(647492); try { $tv->authenticate(); } catch (Exception $e) { die('Authentication failed, I am sorry.'); } file_put_contents('screen.jpeg', $tv->queryData(TV_INFO_SCREEN));