Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
technical:api-profiles [2025/04/02 10:14] – created system | technical:api-profiles [2025/04/02 12:51] (current) – system | ||
---|---|---|---|
Line 9: | Line 9: | ||
* Each **Permanent User**, **Voucher** or **BYOD Device** has to belong to a **Profile** and **Realm** in order to be useful to RADIUS. | * Each **Permanent User**, **Voucher** or **BYOD Device** has to belong to a **Profile** and **Realm** in order to be useful to RADIUS. | ||
* Before we can bulk import Permanent Users using a CSV file, we need to ensure that all the profiles used by the users in the CSV file already exist. | * Before we can bulk import Permanent Users using a CSV file, we need to ensure that all the profiles used by the users in the CSV file already exist. | ||
- | * In this page we will show you how to read the profile names from a text file and then add each one using an API call. | + | * In this page we will show you how to read profile names from a text file and then add each one to RADIUSdesk |
* We will use PHP but the principles can be applied using any programming language. | * We will use PHP but the principles can be applied using any programming language. | ||
Line 15: | Line 15: | ||
====== Add Profiles From List ====== | ====== Add Profiles From List ====== | ||
- | * We use the Authentication | + | |
+ | <file text names.txt> | ||
+ | MzanziFibre-12/ | ||
+ | MzanziFibre-25/ | ||
+ | MzanziFibre-25/ | ||
+ | MzanziFibre-50/ | ||
+ | MzanziFibre-100/ | ||
+ | MzanziFibre-100/ | ||
+ | MzanziFibre-250/ | ||
+ | MzanziFibre-250/ | ||
+ | MzanziFibre-250/ | ||
+ | MzanziFibre-400/ | ||
+ | MzanziFibre-500/ | ||
+ | MzanziFibre-1000/ | ||
+ | MzanziFibre-1000/ | ||
+ | </ | ||
+ | |||
+ | | ||
+ | <file php add_profiles.php> | ||
+ | <?php | ||
+ | |||
+ | // Configuration | ||
+ | $api_url = ' | ||
+ | $names_file = ' | ||
+ | $token = ' | ||
+ | $cloud_id = 56; // replace with the Cloud ID that you want to work on. | ||
+ | |||
+ | // Read names from file | ||
+ | $names = file($names_file, | ||
+ | |||
+ | // Set API payload | ||
+ | $payload = [ | ||
+ | // | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ]; | ||
+ | |||
+ | // Loop through names and call API | ||
+ | foreach ($names as $name) { | ||
+ | $payload[' | ||
+ | $json_payload = json_encode($payload); | ||
+ | $ch = curl_init($api_url); | ||
+ | curl_setopt($ch, | ||
+ | curl_setopt($ch, | ||
+ | curl_setopt($ch, | ||
+ | curl_setopt($ch, | ||
+ | |||
+ | $response = curl_exec($ch); | ||
+ | curl_close($ch); | ||
+ | echo "Added $name: $response\n"; | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * The server' | ||
+ | * The Token can be found when you edit an Admin. | ||
+ | <panel type=" | ||
+ | {{: | ||
+ | </ | ||
+ | * The Cloud ID is listed under the Cloud Applet. | ||
+ | <panel type=" | ||
+ | {{: | ||
+ | </ | ||
+ | * Below is the result of our script: | ||
+ | <panel type=" | ||
+ | {{: | ||
+ | </ | ||