@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
| 5 | 5 | |
| 6 | - require $vdir.'/../vendor/autoload.php'; |
|
| 6 | + require $vdir.'/../vendor/autoload.php'; |
|
| 7 | 7 | |
| 8 | 8 | use Route4Me\Route4Me; |
| 9 | 9 | use Route4Me\Route; |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
| 4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
| 5 | 5 | |
| 6 | 6 | require $vdir.'/../vendor/autoload.php'; |
| 7 | 7 | //require __DIR__.'/../vendor/autoload.php';; |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
| 5 | 5 | |
| 6 | - require $vdir.'/../vendor/autoload.php'; |
|
| 6 | + require $vdir.'/../vendor/autoload.php'; |
|
| 7 | 7 | |
| 8 | 8 | use Route4Me\Route4Me; |
| 9 | 9 | use Route4Me\Route; |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Route4Me; |
| 3 | 3 | |
| 4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
| 4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
| 5 | 5 | |
| 6 | 6 | require $vdir.'/../vendor/autoload.php'; |
| 7 | 7 | //require __DIR__.'/../vendor/autoload.php';; |
@@ -11,174 +11,174 @@ |
||
| 11 | 11 | class MyQException extends \Exception {} |
| 12 | 12 | class MyQ { |
| 13 | 13 | |
| 14 | - /** @var string|null $username contains the username used to authenticate with the MyQ API */ |
|
| 15 | - protected $username = null; |
|
| 16 | - /** @var string|null $password contains the password used to authenticate with the MyQ API */ |
|
| 17 | - protected $password = null; |
|
| 18 | - /** @var string|null $appId is the application ID used to register with the MyQ API */ |
|
| 19 | - protected $appId = 'NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx'; |
|
| 20 | - //protected $appId = 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2fi'; |
|
| 21 | - /** @var string|null $securityToken is the auth token returned after a successful login */ |
|
| 22 | - protected $securityToken = null; |
|
| 23 | - /** @var string|null $userAgent is the User-Agent header value sent with each API request */ |
|
| 24 | - protected $userAgent = 'Chamberlain/3.4.1'; |
|
| 25 | - /** @var string|null $culture is the API culture code for the API */ |
|
| 26 | - protected $culture = 'en'; |
|
| 27 | - /** @var string|null $contentType is the content type used for all cURL requests */ |
|
| 28 | - protected $contentType = 'application/json'; |
|
| 29 | - /** @var array $headers contain HTTP headers for cURL requests */ |
|
| 30 | - protected $_headers = array(); |
|
| 31 | - protected $_deviceId = null; |
|
| 32 | - protected $_locationName = null; |
|
| 33 | - protected $_doorName = null; |
|
| 34 | - protected $_loginUrl = 'https://myqexternal.myqdevice.com/api/v4/User/Validate'; |
|
| 35 | - protected $_getDeviceDetailUrl = 'https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get?&filterOn=true'; |
|
| 36 | - protected $_putDeviceStateUrl = '/api/v4/DeviceAttribute/PutDeviceAttribute'; |
|
| 37 | - /** @var resource|null $_conn is the web connection to the MyQ API */ |
|
| 38 | - protected $_conn = null; |
|
| 39 | - /** |
|
| 40 | - * Initializes class. Optionally allows user to override variables |
|
| 41 | - * |
|
| 42 | - * @param array $params A associative array for overwriting class variables |
|
| 43 | - * |
|
| 44 | - * @return MyQ |
|
| 45 | - */ |
|
| 46 | - public function __construct ($params = array()) { |
|
| 47 | - // Overwrite class variables |
|
| 48 | - foreach ($params as $k => $v) { |
|
| 49 | - $this->$k = $v; |
|
| 50 | - } |
|
| 51 | - // Initialize cURL request headers |
|
| 52 | - if (sizeof($this->_headers) == 0) { |
|
| 53 | - $this->_headers = array ( |
|
| 54 | - 'MyQApplicationId' => $this->appId, |
|
| 55 | - 'Culture' => $this->culture, |
|
| 56 | - 'Content-Type' => $this->contentType, |
|
| 57 | - 'User-Agent' => $this->userAgent, |
|
| 58 | - ); |
|
| 59 | - } |
|
| 60 | - // Initialize cURL connection |
|
| 61 | - $this->_init(); |
|
| 62 | - return $this; |
|
| 63 | - } |
|
| 64 | - /** |
|
| 65 | - * Perform a login request |
|
| 66 | - * |
|
| 67 | - * @param string|null $username Username to use when logging in |
|
| 68 | - * @param string|null $password Password to use for logging in |
|
| 69 | - * |
|
| 70 | - * @return MyQ |
|
| 71 | - */ |
|
| 72 | - public function login ($username = null, $password = null) { |
|
| 73 | - // Set username/password if not null |
|
| 74 | - if (!is_null($username)) { |
|
| 75 | - $this->username = $username; |
|
| 76 | - } |
|
| 77 | - if (!is_null($password)) { |
|
| 78 | - $this->password = $password; |
|
| 79 | - } |
|
| 80 | - // confirm that we have a valid username/password |
|
| 81 | - $error = array(); |
|
| 82 | - if (is_null($this->username)) { |
|
| 83 | - $error[] = 'username'; |
|
| 84 | - } |
|
| 85 | - if (is_null($this->password)) { |
|
| 86 | - $error[] = 'password'; |
|
| 87 | - } |
|
| 88 | - if (sizeof($error) > 0) { |
|
| 89 | - throw new MyQException('Missing required auth credential: ' . implode(',', $error)); |
|
| 90 | - } |
|
| 91 | - $this->_login(); |
|
| 92 | - } |
|
| 93 | - public function getState () { |
|
| 94 | - $this->_getDetails(); |
|
| 95 | - $timeInState = time() - $this->_doorStateTime; |
|
| 96 | - echo implode(',', array ( |
|
| 97 | - $this->_locationName, |
|
| 98 | - $this->_doorName, |
|
| 99 | - $this->_doorState, |
|
| 100 | - (int)$timeInState, |
|
| 101 | - )); |
|
| 102 | - } |
|
| 14 | + /** @var string|null $username contains the username used to authenticate with the MyQ API */ |
|
| 15 | + protected $username = null; |
|
| 16 | + /** @var string|null $password contains the password used to authenticate with the MyQ API */ |
|
| 17 | + protected $password = null; |
|
| 18 | + /** @var string|null $appId is the application ID used to register with the MyQ API */ |
|
| 19 | + protected $appId = 'NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx'; |
|
| 20 | + //protected $appId = 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2fi'; |
|
| 21 | + /** @var string|null $securityToken is the auth token returned after a successful login */ |
|
| 22 | + protected $securityToken = null; |
|
| 23 | + /** @var string|null $userAgent is the User-Agent header value sent with each API request */ |
|
| 24 | + protected $userAgent = 'Chamberlain/3.4.1'; |
|
| 25 | + /** @var string|null $culture is the API culture code for the API */ |
|
| 26 | + protected $culture = 'en'; |
|
| 27 | + /** @var string|null $contentType is the content type used for all cURL requests */ |
|
| 28 | + protected $contentType = 'application/json'; |
|
| 29 | + /** @var array $headers contain HTTP headers for cURL requests */ |
|
| 30 | + protected $_headers = array(); |
|
| 31 | + protected $_deviceId = null; |
|
| 32 | + protected $_locationName = null; |
|
| 33 | + protected $_doorName = null; |
|
| 34 | + protected $_loginUrl = 'https://myqexternal.myqdevice.com/api/v4/User/Validate'; |
|
| 35 | + protected $_getDeviceDetailUrl = 'https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get?&filterOn=true'; |
|
| 36 | + protected $_putDeviceStateUrl = '/api/v4/DeviceAttribute/PutDeviceAttribute'; |
|
| 37 | + /** @var resource|null $_conn is the web connection to the MyQ API */ |
|
| 38 | + protected $_conn = null; |
|
| 39 | + /** |
|
| 40 | + * Initializes class. Optionally allows user to override variables |
|
| 41 | + * |
|
| 42 | + * @param array $params A associative array for overwriting class variables |
|
| 43 | + * |
|
| 44 | + * @return MyQ |
|
| 45 | + */ |
|
| 46 | + public function __construct ($params = array()) { |
|
| 47 | + // Overwrite class variables |
|
| 48 | + foreach ($params as $k => $v) { |
|
| 49 | + $this->$k = $v; |
|
| 50 | + } |
|
| 51 | + // Initialize cURL request headers |
|
| 52 | + if (sizeof($this->_headers) == 0) { |
|
| 53 | + $this->_headers = array ( |
|
| 54 | + 'MyQApplicationId' => $this->appId, |
|
| 55 | + 'Culture' => $this->culture, |
|
| 56 | + 'Content-Type' => $this->contentType, |
|
| 57 | + 'User-Agent' => $this->userAgent, |
|
| 58 | + ); |
|
| 59 | + } |
|
| 60 | + // Initialize cURL connection |
|
| 61 | + $this->_init(); |
|
| 62 | + return $this; |
|
| 63 | + } |
|
| 64 | + /** |
|
| 65 | + * Perform a login request |
|
| 66 | + * |
|
| 67 | + * @param string|null $username Username to use when logging in |
|
| 68 | + * @param string|null $password Password to use for logging in |
|
| 69 | + * |
|
| 70 | + * @return MyQ |
|
| 71 | + */ |
|
| 72 | + public function login ($username = null, $password = null) { |
|
| 73 | + // Set username/password if not null |
|
| 74 | + if (!is_null($username)) { |
|
| 75 | + $this->username = $username; |
|
| 76 | + } |
|
| 77 | + if (!is_null($password)) { |
|
| 78 | + $this->password = $password; |
|
| 79 | + } |
|
| 80 | + // confirm that we have a valid username/password |
|
| 81 | + $error = array(); |
|
| 82 | + if (is_null($this->username)) { |
|
| 83 | + $error[] = 'username'; |
|
| 84 | + } |
|
| 85 | + if (is_null($this->password)) { |
|
| 86 | + $error[] = 'password'; |
|
| 87 | + } |
|
| 88 | + if (sizeof($error) > 0) { |
|
| 89 | + throw new MyQException('Missing required auth credential: ' . implode(',', $error)); |
|
| 90 | + } |
|
| 91 | + $this->_login(); |
|
| 92 | + } |
|
| 93 | + public function getState () { |
|
| 94 | + $this->_getDetails(); |
|
| 95 | + $timeInState = time() - $this->_doorStateTime; |
|
| 96 | + echo implode(',', array ( |
|
| 97 | + $this->_locationName, |
|
| 98 | + $this->_doorName, |
|
| 99 | + $this->_doorState, |
|
| 100 | + (int)$timeInState, |
|
| 101 | + )); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | public function getDetails() { |
| 105 | 105 | return $this->_getDetails(); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - private function _init () { |
|
| 109 | - if (!isset($this->_conn)) { |
|
| 110 | - $this->_conn = curl_init(); |
|
| 111 | - curl_setopt_array($this->_conn, array ( |
|
| 112 | - CURLOPT_RETURNTRANSFER => true, |
|
| 113 | - CURLOPT_ENCODING => "", |
|
| 114 | - CURLOPT_MAXREDIRS => 10, |
|
| 115 | - CURLOPT_TIMEOUT => 30, |
|
| 116 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
| 117 | - CURLOPT_FAILONERROR => true, |
|
| 118 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 119 | - CURLOPT_FRESH_CONNECT => true, |
|
| 120 | - CURLOPT_FORBID_REUSE => true, |
|
| 121 | - CURLOPT_USERAGENT => $this->userAgent, |
|
| 122 | - )); |
|
| 123 | - } |
|
| 124 | - $this->_setHeaders(); |
|
| 125 | - } |
|
| 126 | - private function _setHeaders () { |
|
| 127 | - $headers = array(); |
|
| 128 | - foreach ($this->_headers as $k => $v) { |
|
| 129 | - $headers[] = "$k: $v"; |
|
| 130 | - } |
|
| 131 | - curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers); |
|
| 132 | - } |
|
| 133 | - private function _login () { |
|
| 134 | - $this->_init(); |
|
| 135 | - curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST'); |
|
| 136 | - curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl); |
|
| 137 | - $post = json_encode(array('username' => $this->username, 'password' => $this->password)); |
|
| 138 | - curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post); |
|
| 139 | - $output = curl_exec($this->_conn); |
|
| 140 | - $data = json_decode($output); |
|
| 141 | - if ($data == false || !isset($data->SecurityToken)) { |
|
| 142 | - throw new MyQException("Error processing login request: $output"); |
|
| 143 | - } |
|
| 144 | - $this->_headers['SecurityToken'] = $data->SecurityToken; |
|
| 145 | - return $this; |
|
| 146 | - } |
|
| 147 | - private function _getDetails () { |
|
| 148 | - $this->_init(); |
|
| 149 | - curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET'); |
|
| 150 | - curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl); |
|
| 151 | - $output = curl_exec($this->_conn); |
|
| 152 | - $data = json_decode($output); |
|
| 153 | - if ($data == false || !isset($data->Devices)) { |
|
| 154 | - throw new MyQException("Error fetching device details: $output"); |
|
| 155 | - } |
|
| 156 | - // Find our door device ID |
|
| 157 | - foreach ($data->Devices as $device) { |
|
| 158 | - if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) { |
|
| 159 | - // Find location name |
|
| 160 | - foreach ($device->Attributes as $attr) { |
|
| 161 | - if ($attr->AttributeDisplayName == 'desc') { |
|
| 162 | - $this->_locationName = $attr->Value; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 108 | + private function _init () { |
|
| 109 | + if (!isset($this->_conn)) { |
|
| 110 | + $this->_conn = curl_init(); |
|
| 111 | + curl_setopt_array($this->_conn, array ( |
|
| 112 | + CURLOPT_RETURNTRANSFER => true, |
|
| 113 | + CURLOPT_ENCODING => "", |
|
| 114 | + CURLOPT_MAXREDIRS => 10, |
|
| 115 | + CURLOPT_TIMEOUT => 30, |
|
| 116 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
| 117 | + CURLOPT_FAILONERROR => true, |
|
| 118 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 119 | + CURLOPT_FRESH_CONNECT => true, |
|
| 120 | + CURLOPT_FORBID_REUSE => true, |
|
| 121 | + CURLOPT_USERAGENT => $this->userAgent, |
|
| 122 | + )); |
|
| 123 | + } |
|
| 124 | + $this->_setHeaders(); |
|
| 125 | + } |
|
| 126 | + private function _setHeaders () { |
|
| 127 | + $headers = array(); |
|
| 128 | + foreach ($this->_headers as $k => $v) { |
|
| 129 | + $headers[] = "$k: $v"; |
|
| 130 | + } |
|
| 131 | + curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers); |
|
| 132 | + } |
|
| 133 | + private function _login () { |
|
| 134 | + $this->_init(); |
|
| 135 | + curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST'); |
|
| 136 | + curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl); |
|
| 137 | + $post = json_encode(array('username' => $this->username, 'password' => $this->password)); |
|
| 138 | + curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post); |
|
| 139 | + $output = curl_exec($this->_conn); |
|
| 140 | + $data = json_decode($output); |
|
| 141 | + if ($data == false || !isset($data->SecurityToken)) { |
|
| 142 | + throw new MyQException("Error processing login request: $output"); |
|
| 143 | + } |
|
| 144 | + $this->_headers['SecurityToken'] = $data->SecurityToken; |
|
| 145 | + return $this; |
|
| 146 | + } |
|
| 147 | + private function _getDetails () { |
|
| 148 | + $this->_init(); |
|
| 149 | + curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET'); |
|
| 150 | + curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl); |
|
| 151 | + $output = curl_exec($this->_conn); |
|
| 152 | + $data = json_decode($output); |
|
| 153 | + if ($data == false || !isset($data->Devices)) { |
|
| 154 | + throw new MyQException("Error fetching device details: $output"); |
|
| 155 | + } |
|
| 156 | + // Find our door device ID |
|
| 157 | + foreach ($data->Devices as $device) { |
|
| 158 | + if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) { |
|
| 159 | + // Find location name |
|
| 160 | + foreach ($device->Attributes as $attr) { |
|
| 161 | + if ($attr->AttributeDisplayName == 'desc') { |
|
| 162 | + $this->_locationName = $attr->Value; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - $this->_deviceId = $device->MyQDeviceId; |
|
| 168 | - foreach ($device->Attributes as $attr) { |
|
| 169 | - switch ($attr->AttributeDisplayName) { |
|
| 170 | - case 'desc': |
|
| 171 | - $this->_doorName = $attr->Value; |
|
| 172 | - break; |
|
| 173 | - case 'doorstate': |
|
| 174 | - $this->_doorState = $attr->Value; |
|
| 175 | - // UpdatedTime is a timestamp in ms, so we truncate |
|
| 176 | - $this->_doorStateTime = (int)$attr->UpdatedTime / 1000; |
|
| 177 | - break; |
|
| 178 | - default: |
|
| 179 | - continue; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } |
|
| 167 | + $this->_deviceId = $device->MyQDeviceId; |
|
| 168 | + foreach ($device->Attributes as $attr) { |
|
| 169 | + switch ($attr->AttributeDisplayName) { |
|
| 170 | + case 'desc': |
|
| 171 | + $this->_doorName = $attr->Value; |
|
| 172 | + break; |
|
| 173 | + case 'doorstate': |
|
| 174 | + $this->_doorState = $attr->Value; |
|
| 175 | + // UpdatedTime is a timestamp in ms, so we truncate |
|
| 176 | + $this->_doorStateTime = (int)$attr->UpdatedTime / 1000; |
|
| 177 | + break; |
|
| 178 | + default: |
|
| 179 | + continue; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | 184 | } |
| 185 | 185 | \ No newline at end of file |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return MyQ |
| 45 | 45 | */ |
| 46 | - public function __construct ($params = array()) { |
|
| 46 | + public function __construct($params = array()) { |
|
| 47 | 47 | // Overwrite class variables |
| 48 | 48 | foreach ($params as $k => $v) { |
| 49 | 49 | $this->$k = $v; |
| 50 | 50 | } |
| 51 | 51 | // Initialize cURL request headers |
| 52 | - if (sizeof($this->_headers) == 0) { |
|
| 53 | - $this->_headers = array ( |
|
| 52 | + if (sizeof($this->_headers)==0) { |
|
| 53 | + $this->_headers = array( |
|
| 54 | 54 | 'MyQApplicationId' => $this->appId, |
| 55 | 55 | 'Culture' => $this->culture, |
| 56 | 56 | 'Content-Type' => $this->contentType, |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return MyQ |
| 71 | 71 | */ |
| 72 | - public function login ($username = null, $password = null) { |
|
| 72 | + public function login($username = null, $password = null) { |
|
| 73 | 73 | // Set username/password if not null |
| 74 | 74 | if (!is_null($username)) { |
| 75 | 75 | $this->username = $username; |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | if (is_null($this->password)) { |
| 86 | 86 | $error[] = 'password'; |
| 87 | 87 | } |
| 88 | - if (sizeof($error) > 0) { |
|
| 89 | - throw new MyQException('Missing required auth credential: ' . implode(',', $error)); |
|
| 88 | + if (sizeof($error)>0) { |
|
| 89 | + throw new MyQException('Missing required auth credential: '.implode(',', $error)); |
|
| 90 | 90 | } |
| 91 | 91 | $this->_login(); |
| 92 | 92 | } |
| 93 | - public function getState () { |
|
| 93 | + public function getState() { |
|
| 94 | 94 | $this->_getDetails(); |
| 95 | 95 | $timeInState = time() - $this->_doorStateTime; |
| 96 | - echo implode(',', array ( |
|
| 96 | + echo implode(',', array( |
|
| 97 | 97 | $this->_locationName, |
| 98 | 98 | $this->_doorName, |
| 99 | 99 | $this->_doorState, |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | return $this->_getDetails(); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - private function _init () { |
|
| 108 | + private function _init() { |
|
| 109 | 109 | if (!isset($this->_conn)) { |
| 110 | 110 | $this->_conn = curl_init(); |
| 111 | - curl_setopt_array($this->_conn, array ( |
|
| 111 | + curl_setopt_array($this->_conn, array( |
|
| 112 | 112 | CURLOPT_RETURNTRANSFER => true, |
| 113 | 113 | CURLOPT_ENCODING => "", |
| 114 | 114 | CURLOPT_MAXREDIRS => 10, |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | $this->_setHeaders(); |
| 125 | 125 | } |
| 126 | - private function _setHeaders () { |
|
| 126 | + private function _setHeaders() { |
|
| 127 | 127 | $headers = array(); |
| 128 | 128 | foreach ($this->_headers as $k => $v) { |
| 129 | 129 | $headers[] = "$k: $v"; |
| 130 | 130 | } |
| 131 | 131 | curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers); |
| 132 | 132 | } |
| 133 | - private function _login () { |
|
| 133 | + private function _login() { |
|
| 134 | 134 | $this->_init(); |
| 135 | 135 | curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST'); |
| 136 | 136 | curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl); |
@@ -138,27 +138,27 @@ discard block |
||
| 138 | 138 | curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post); |
| 139 | 139 | $output = curl_exec($this->_conn); |
| 140 | 140 | $data = json_decode($output); |
| 141 | - if ($data == false || !isset($data->SecurityToken)) { |
|
| 141 | + if ($data==false || !isset($data->SecurityToken)) { |
|
| 142 | 142 | throw new MyQException("Error processing login request: $output"); |
| 143 | 143 | } |
| 144 | 144 | $this->_headers['SecurityToken'] = $data->SecurityToken; |
| 145 | 145 | return $this; |
| 146 | 146 | } |
| 147 | - private function _getDetails () { |
|
| 147 | + private function _getDetails() { |
|
| 148 | 148 | $this->_init(); |
| 149 | 149 | curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET'); |
| 150 | 150 | curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl); |
| 151 | 151 | $output = curl_exec($this->_conn); |
| 152 | 152 | $data = json_decode($output); |
| 153 | - if ($data == false || !isset($data->Devices)) { |
|
| 153 | + if ($data==false || !isset($data->Devices)) { |
|
| 154 | 154 | throw new MyQException("Error fetching device details: $output"); |
| 155 | 155 | } |
| 156 | 156 | // Find our door device ID |
| 157 | 157 | foreach ($data->Devices as $device) { |
| 158 | - if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) { |
|
| 158 | + if (stripos($device->MyQDeviceTypeName, "Gateway")!==false) { |
|
| 159 | 159 | // Find location name |
| 160 | 160 | foreach ($device->Attributes as $attr) { |
| 161 | - if ($attr->AttributeDisplayName == 'desc') { |
|
| 161 | + if ($attr->AttributeDisplayName=='desc') { |
|
| 162 | 162 | $this->_locationName = $attr->Value; |
| 163 | 163 | } |
| 164 | 164 | } |