Good evening, can someone perhaps assist.
I want to retrieve a sites usage and cap left before it gets fuped (for example when you hover over a client Rule tab under the customers assigned Service) when i run my api get request i only receive a Results OK and then a blank Array with no info. Our configuration for Splynx is Mikrotik API accounting.
Thankyou,
Any assistance would be appreciated.
Hello, please attach your code here
Hi,
Thank you for getting back to me, please find my code snip it, i cannot attach since i am new to this form.
$api_url = $_GET[âIPâ];;
$key = $_GET[âsplloginâ];
$secret = $_GET[âsplpasswordâ];
$api = new SplynxAPI($api_url);
$api->setVersion(SplynxApi::API_VERSION_2);
$isAuthorized = $api->login([
âauth_typeâ => SplynxApi::AUTH_TYPE_API_KEY,
âkeyâ => $key,
âsecretâ => $secret,
]);
if (!$isAuthorized) {
exit(âAuthorization failed!\nâ);
}
$locationsApiUrl = âadmin/fup/usage/26?with_texts=trueâ;
print âUser Status\nâ;
$result = $api->api_call_get($locationsApiUrl);
print "Result: ";
if ($result) {
print âOk!\nâ;
print_r($api->response);
} else {
print âFail! Error code: $api->response_code\nâ;
print_r($api->response);
}
print â\n-------------------------------------------------\nâ;
Please take a look at my PHP script example, i am using authorization by API key, to create API key go to Administration/API keys -> add API key and permissions.
Unfortunately you canât retrieve FUP usage by admin authorization.
<?php
include 'SplynxApi.php'; // your API source
$api_url = 'http://192.168.100.230/'; // please set your Splynx URL
$api = new SplynxApi($api_url);
$api->setVersion(SplynxApi::API_VERSION_2);
$api->login([
'auth_type'=> SplynxApi::AUTH_TYPE_API_KEY,
'key' => '2f06f1c0ced6642b2f062cb4f4c6de47',
'secret' => '761c46d8d4f6c1be47036a0695c14996',
]); // authorization by API key with correct permissions
$api->api_call_get('admin/fup/usage/25');
Good afternoon Mykhailo,
Thank you so much for getting back to me, i have used that authentication method which works but my reply when i do the API GET is as follows;
User Status
Result: Ok!
Array
(
)
I only receive a blank array reply, the service ID that i use is definitely for a site that exists. Please see my code below excluding authentication.
print âUser Status\nâ;
$result = $api->api_call_get(âadmin/fup/usage/26?with_texts=trueâ);
print "Result: ";
if ($result) {
print âOk!\nâ;
print_r($api->response);
} else {
print âFail! Error code: $api->response_code\nâ;
print_r($api->response);
}
print â\n-------------------------------------------------\nâ;
Try to set up CAP amount to the internet tariff of your internet service. It should works after that.
Please check an attachments:
Hi Mykhailo,
Iâm not sure what i am missing but i do not have the CAP tab under the FUP configuration for my internet Plans.
Thank you.
Hello, you have to enable CAP in Config/Integrations/Main modules:
Hi Mykhailo,
Thank you for your assistance, this has been resolved.
1 Like