<?php
// Configuration
$api_url = 'http://127.0.0.1/cake4/rd_cake/profiles/simple_add.json';
$names_file = 'names.txt'; // replace with your text file
$token = '617088c3-f908-4f1f-8091-82223c571cc67'; // replace with your token (If you want to add the profile as system wide, you will need root's token)
$cloud_id = 56; // replace with the Cloud ID that you want to work on.
// Read names from file
$names = file($names_file, FILE_IGNORE_NEW_LINES);
// Set API payload
$payload = [
// "for_system" => "on",
"id" => "",
"name" => "",
"data_limit_enabled" => "false",
"time_limit_enabled" => "false",
"speed_limit_enabled" => "false",
"logintime_1_span" => "disabled",
"logintime_2_span" => "disabled",
"logintime_3_span" => "disabled",
"session_limit_enabled" => "false",
"adv_data_limit_enabled"=> "false",
"adv_time_limit_enabled"=> "false",
"token" => $token,
"sel_language" => "4_4",
"cloud_id" => $cloud_id
];
// Loop through names and call API
foreach ($names as $name) {
$payload['name'] = $name;
$json_payload = json_encode($payload);
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($ch);
curl_close($ch);
echo "Added $name: $response\n";
}
?>