Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11c132b263 | ||
|
|
5a64a0c844 | ||
|
|
898703db5c | ||
|
|
1aa8956445 | ||
|
|
77c4b17003 | ||
|
|
089b0b77ae | ||
|
|
0263c47be9 |
13
README.md
13
README.md
@@ -1,5 +1,10 @@
|
||||
## UniFi Controller API client class
|
||||
|
||||
[](https://github.com/Art-of-WiFi/UniFi-API-client/blob/main/LICENSE)
|
||||
[](https://packagist.org/packages/art-of-wifi/unifi-api-client)
|
||||
[](https://packagist.org/packages/art-of-wifi/unifi-api-client)
|
||||
[](https://packagist.org/packages/art-of-wifi/unifi-api-client)
|
||||
|
||||
A PHP class that provides access to Ubiquiti's [**UniFi Network Application**](https://unifi-network.ui.com/) API.
|
||||
|
||||
This class is used by our API Browser tool, which can be found
|
||||
@@ -11,10 +16,10 @@ easy inclusion in your projects. See the [installation instructions](#Installati
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Software | Versions |
|
||||
|--------------------------------------|-----------------------------------------------------|
|
||||
| UniFi Network Application/controller | 5.X.X, 6.X.X, 7.X.X, 8.X.X (**8.5.6 is confirmed**) |
|
||||
| UniFi OS | 3.X, 4.X (**4.1.15 is confirmed**) |
|
||||
| Software | Versions |
|
||||
|--------------------------------------|------------------------------------------------------|
|
||||
| UniFi Network Application/controller | 5.x, 6.x, 7.x, 8.x, 9.0.x (**9.0.101 is confirmed**) |
|
||||
| UniFi OS | 3.x, 4.1.x (**4.1.15 is confirmed**) |
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace UniFi_API;
|
||||
class Client
|
||||
{
|
||||
/** Constants. */
|
||||
const CLASS_VERSION = '1.1.102';
|
||||
const CLASS_VERSION = '1.1.104';
|
||||
const CURL_METHODS_ALLOWED = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
|
||||
const DEFAULT_CURL_METHOD = 'GET';
|
||||
|
||||
@@ -87,8 +87,8 @@ class Client
|
||||
string $user,
|
||||
string $password,
|
||||
string $baseurl = 'https://127.0.0.1:8443',
|
||||
string $site = 'default',
|
||||
string $version = '8.0.28',
|
||||
?string $site = 'default',
|
||||
?string $version = '8.0.28',
|
||||
bool $ssl_verify = false,
|
||||
string $unificookie_name = 'unificookie'
|
||||
)
|
||||
@@ -3899,12 +3899,12 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value for the private property $curl_http_version.
|
||||
* Set the value for the private property $curl_http_version.
|
||||
*
|
||||
* @note As of cURL version 7.62.0 the default value is CURL_HTTP_VERSION_2TLS which may cause issues,
|
||||
* this method allows you to set the value to CURL_HTTP_VERSION_1_1 when needed.
|
||||
* @param int $http_version new value for $curl_http_version, CURL_HTTP_VERSION_1_1 int(2) or
|
||||
* CURL_HTTP_VERSION_2TLS int(4) are recommended
|
||||
* @note As of cURL version 7.62.0 the default value is CURL_HTTP_VERSION_2TLS. This can cause issues in certain
|
||||
* cases, this method allows you to set the value to CURL_HTTP_VERSION_1_1 when needed.
|
||||
* @param int $http_version new value for $curl_http_version. Values using PHP constants CURL_HTTP_VERSION_1_1 or
|
||||
* CURL_HTTP_VERSION_2TLS are recommended.
|
||||
* @return bool whether the request was successful or not
|
||||
* @see https://curl.se/libcurl/c/CURLOPT_HTTP_VERSION.html
|
||||
*/
|
||||
@@ -4304,11 +4304,8 @@ class Client
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
/** Login again. */
|
||||
$this->login();
|
||||
|
||||
/** When the re-login was successful, execute the same cURL request again. */
|
||||
if ($this->is_logged_in) {
|
||||
/** Re-login, and if successful, execute the same cURL request again. */
|
||||
if ($this->login()) {
|
||||
if ($this->debug) {
|
||||
error_log(__FUNCTION__ . ': re-logged in, calling exec_curl again');
|
||||
}
|
||||
@@ -4359,7 +4356,7 @@ class Client
|
||||
{
|
||||
$ch = curl_init();
|
||||
$curl_options = [
|
||||
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS,
|
||||
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP,
|
||||
CURLOPT_HTTP_VERSION => $this->curl_http_version,
|
||||
CURLOPT_SSL_VERIFYPEER => $this->curl_ssl_verify_peer,
|
||||
CURLOPT_SSL_VERIFYHOST => $this->curl_ssl_verify_host,
|
||||
|
||||
Reference in New Issue
Block a user