Prepaid-cards API

Hello,
I am using API to generate vouchers for my Hotspot network.
On my Mikrotik hotspot login page, I only have the Field username active.
I need to authenticate users via username ($login) only, the password filed is hidden but I have set a static password to be used by all users.

My question is can I include attribute “password” in my voucher generating API script…?
$voucher = $voucher = array(
‘expired_by’ => ‘valid_date’,
‘location_id’ => ‘0’,
‘partner_id’ => ‘0’,
‘pool_id’ => ‘-1’,
‘prefix’ => ‘FW_’ . rand(1, 10000),
’password’ => ‘MYSTATICPASS’,
‘price’ => rand(1, 100),
‘quantity’ => 1,
‘phone’ => $phone,
‘speed_download’ => rand(100, 2000),
‘speed_upload’ => rand(100, 2000),
‘time_expired_selector’ => ‘minutes’,
‘time_online’ => rand(100, 2000),
‘time_online_selector’ => ‘hours’,
‘traffic_all_total’ => rand(1000, 5000),
‘traffic_in_total’ => rand(1000, 5000),
‘traffic_out_total’ => rand(1000, 5000),
‘valid_till’ => date(‘Y-m-d’, time() + rand(1000, 10000000))
);

I tried running the above code but, the password attribute doesn’t get submitted… instead I have an auto generated password.

Kindly assist if this is possible…

Many thanks

Hi William,

please check my code below:

$api_url = ‘http://you_server_ip/’; //
$key = “your_key”;
$secret = “your_secret”;
$api = new SplynxAPI($api_url, $key, $secret);

// create a new serie
$arr = [
‘expired_by’ => ‘valid_date’,
‘location_id’ => ‘0’,
‘partner_id’ => ‘0’,
‘pool_id’ => ‘-1’,
‘prefix’ => ‘FW_’ . rand(1, 10000),
‘price’ => rand(1, 100),
‘quantity’ => 2,
‘speed_download’ => rand(100, 2000),
‘speed_upload’ => rand(100, 2000),
‘time_expired_selector’ => ‘minutes’,
‘time_online’ => rand(100, 2000),
‘time_online_selector’ => ‘hours’,
‘traffic_all_total’ => rand(1000, 5000),
‘traffic_in_total’ => rand(1000, 5000),
‘traffic_out_total’ => rand(1000, 5000),
‘valid_till’ => date(‘Y-m-d’, time() + rand(1000, 10000000))
];
$api->api_call_post(‘admin/customers/prepaid-cards-series’,$arr);
$serie = $api->response;

// get data from the serie
$api->api_call_get(‘admin/customers/prepaid-cards-series/’.$serie[‘serie’]);
$vauchers = $api->response;
if (!empty($vauchers)){
foreach ($vauchers as &$card) {

// change password for each card
$pass = [
‘password’ => ‘bla-bla-bla’
];
$api->api_call_put(‘admin/customers/prepaid-cards’,$card[‘id’],$pass);
}

}

hope it will be useful for you.

Thanks

Thanks a lot Nik… This is exactly what I needed… (y)