Compare commits

...

7 Commits

Author SHA1 Message Date
malle-pietje
11c132b263 bumped version to 1.1.104 2025-01-02 10:54:03 +01:00
malle-pietje
5a64a0c844 added curl option to specifically support http (originally suggested by @Kyouma54 in PR #251) 2025-01-02 10:47:01 +01:00
malle-pietje
898703db5c further tweaks to README 2024-12-19 12:17:45 +01:00
malle-pietje
1aa8956445 added note re support for version 9.X 2024-12-19 12:11:25 +01:00
malle-pietje
77c4b17003 added shields to README 2024-12-19 12:05:51 +01:00
malle-pietje
089b0b77ae bumped version for next release 2024-12-19 11:15:12 +01:00
malle-pietje
0263c47be9 minor changes 2024-12-19 11:13:10 +01:00
2 changed files with 20 additions and 18 deletions

View File

@@ -1,5 +1,10 @@
## UniFi Controller API client class
[![License](https://img.shields.io/github/license/Art-of-WiFi/UniFi-API-client)](https://github.com/Art-of-WiFi/UniFi-API-client/blob/main/LICENSE)
[![Packagist Version](https://img.shields.io/packagist/v/art-of-wifi/unifi-api-client)](https://packagist.org/packages/art-of-wifi/unifi-api-client)
[![Downloads](https://img.shields.io/packagist/dt/art-of-wifi/unifi-api-client)](https://packagist.org/packages/art-of-wifi/unifi-api-client)
[![PHP Version](https://img.shields.io/packagist/php-v/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

View File

@@ -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,