Fup get traffic Usage Issue API

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