Closed istoOi closed 5 years ago
Both fields in the config file ($controllerurl
when using a single-controller configuration and $controllers[X]->url
when using a multi-controller configuration) require a full URL so I believe there's an error in your configuration file.
If you don't agree, please share the full anonymized contents of your config file.
I use a single controller and only configured $controllerurl (https://
<?php
/**
* Copyright (c) 2017, Art of WiFi
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
*/
/**
* Optionally copy/rename this configuration template file to config.php and store all or part of your credentials
*
* IMPORTANT NOTE:
* If credential information is not specified in this file, or the file is not copied to config.php,
* or only part of the credentials are provided, then the API browser will show a form to complete the login
*/
/**
* Single controller configuration
* ===============================
* Update this section with your UniFi controller details and credentials
* Remove or comment out this section when using the Multi controller configuration method
*/
$controlleruser = 'MyUser'; // the user name for access to the UniFi Controller
$controllerpassword = 'MyPass'; // the password for access to the UniFi Controller
$controllerurl = 'https://xxx.xxx.xxx.xxx:8443'; // full url to the UniFi Controller, eg. 'https://22.22.11.11:8443'
$controllername = 'MyController'; // name for this controller
/**
* Multi controller configuration
* ==============================
* Only modify and uncomment this section when NOT using the above Single controller configuration method.
* The number of controllers that can be added is unlimited, just take care to correctly increment the
* index values (0,1,2 etc.)
*
* Please remember to only have one of either two methods active!
*
* IMPORTANT NOTE:
* If you use the multi controller method, then at least the 'name' value is required for each controller entry
*/
/*
$controllers[0] = [
'user' => '', // the user name for access to the UniFi Controller
'password' => '', // the password for access to the UniFi Controller
'url' => '', // full url to the UniFi Controller, eg. 'https://22.22.11.11:8443'
'name' => '' // REQUIRED: name for this controller which will be used in the dropdown menu
];
$controllers[1] = [
'user' => '', // the user name for access to the UniFi Controller
'password' => '', // the password for access to the UniFi Controller
'url' => '', // full url to the UniFi Controller, eg. 'https://22.22.11.11:8443'
'name' => '' // REQUIRED: name for this controller which will be used in the dropdown menu
];
$controllers[2] = [
'user' => 'demo', // the user name for access to the Unifi Controller
'password' => 'demo', // the password for access to the Unifi Controller
'url' => 'https://demo.ubnt.com:443', // full url to the Unifi Controller, eg. 'https://22.22.11.11:8443'
'name' => 'demo.ubnt.com' // REQUIRED: name for this controller which will be used in the dropdown menu
];
*/
/**
* Optionally uncomment and change the default options below
*/
//$cookietimeout = '3600'; // time of inactivity in seconds, after which the PHP session cookie will be refreshed
// after the cookie refresh the site and data collection will need to be selected again
//$theme = 'bootstrap'; // your default theme of choice, pick one from the list below:
// bootstrap, cerulean, cosmo, cyborg, darkly, flatly, journal, lumen, paper
// readable, sandstone, simplex, slate, spacelab, superhero, united, yeti
//$debug = false; // set to true (without quotes) to enable debug output to the browser and the PHP error log
Hmm, very strange.
As you can see the value of $controllerurl
is copied to $controller['url']
here:
https://github.com/Art-of-WiFi/UniFi-API-browser/blob/master/index.php#L170
Which PHP version are you using?
Synology shows 7.0.33-0028 Maybe it's those trims?
The trim and rtrim function calls shouldn't be mangling the URL. What happens if you change line #296 to:
$unifidata = new UniFi_API\Client($controller['user'], $controller['password'], $controller['url'], $site_id);
Hmmm. The line works. And the original line now too. Don't know what has changed. I don't even restarted the Synology NAS. Very strange.
This returns now always a full URL
print_r($controller['url']); echo "<br>"; print_r(trim($controller['url'])); echo "<br>"; print_r(rtrim(trim($controller['url']), '/'));
Could have been caused by a server-side session cookie... in such cases the “reset PHP session” option in the right-hand dropdown menu will help.
thx for the advice
Synology DSM 6.2.1 U6 Web Station + PHP7
After setup i was unable to connect to the controller. Error message suggested that the credentials are wrong. The problem seems to be line ~297 of index.php where $controller['url'] is uesed. This returns just an IP while "vendor\art-of-wifi\unifi-api-client\src\Client.php" needs an url with port. I fixed it by using $controllerurl instead.
$unifidata = new UniFi_API\Client(trim($controller['user']), $controller['password'], $controllerurl, $site_id);