diff --git a/examples/authorize-guest.php b/examples/authorize-guest.php index 0c9d815..70969f4 100644 --- a/examples/authorize-guest.php +++ b/examples/authorize-guest.php @@ -14,11 +14,12 @@ try { // login to the unifi controller API $apiClient->login($config['username'], $config['password']); + // Authorize guest with mac address 01:01:01:01:01:01 for 60 minutes // You need a user with full access to the unifi controller for this call! - $responseBody = $apiClient->authorizeGuest($config['site'], '01:01:01:01:01:01', 60); + $response = $apiClient->authorizeGuest($config['site'], '01:01:01:01:01:01', 60); - print_r(json_decode($responseBody)); + print_r(json_decode($response->getBody(), true)); $apiClient->logout(); @@ -26,7 +27,8 @@ try { echo $e->getMessage() . PHP_EOL; echo '----- Request ------' . PHP_EOL; - echo $e->getRequest()->getBody()->getContents(); + + echo (string) $e->getRequest()->getBody(); echo PHP_EOL; echo '----- Response ------' . PHP_EOL; diff --git a/examples/device-statistics.php b/examples/device-statistics.php index ad5dac8..d63876c 100644 --- a/examples/device-statistics.php +++ b/examples/device-statistics.php @@ -28,7 +28,8 @@ try { echo $e->getMessage() . PHP_EOL; echo '----- Request ------' . PHP_EOL; - echo $e->getRequest()->getBody()->getContents(); + + echo (string) $e->getRequest()->getBody(); echo PHP_EOL; echo '----- Response ------' . PHP_EOL; diff --git a/examples/unauthorize-guest.php b/examples/unauthorize-guest.php index 42f2af8..f3491df 100644 --- a/examples/unauthorize-guest.php +++ b/examples/unauthorize-guest.php @@ -16,9 +16,9 @@ try { // Revoke authorization for guest with mac address 01:01:01:01:01:01 // You need a user with full access to the unifi controller for this call! - $responseBody = $apiClient->unauthorizeGuest($config['site'], '01:01:01:01:01:01'); + $response = $apiClient->unauthorizeGuest($config['site'], '01:01:01:01:01:01'); - print_r(json_decode($responseBody)); + print_r(json_decode($response->getBody(), true)); $apiClient->logout(); @@ -26,7 +26,8 @@ try { echo $e->getMessage() . PHP_EOL; echo '----- Request ------' . PHP_EOL; - echo $e->getRequest()->getBody()->getContents(); + + echo (string) $e->getRequest()->getBody(); echo PHP_EOL; echo '----- Response ------' . PHP_EOL; diff --git a/src/Client.php b/src/Client.php index a62f2d9..c1d6380 100644 --- a/src/Client.php +++ b/src/Client.php @@ -78,7 +78,7 @@ class Client { $this->post( '/api/login', - ['username' => $username, 'password' => $password, 'strict' => true] + ['username' => $username, 'password' => $password] ); }