<?php
print("RADIUSdesk API to Add a Permanent User");
/*
*active active (leave out tocreate disabled account)
address
always_active always_active
*cap_data soft
email
*language 4_4
name
*parent_id 0
*password hotel_room1
phone
*profile_id 9
*realm_id 34
*sel_language 4_4
surname
*token 52190fff-a800-48eb-b1f2-478bc0a80167 (replace with root or access provider's unique token)
*track_acct track_acct
*username hotel_room1
*/
$active = 'active';
$cap_data = 'soft';
$language = '4_4';
$parent_id = 0;
$profile_id = 9;
$realm_id = 34;
$token = '52190fff-a800-48eb-b1f2-478bc0a80167';
$username = 'hotel_room1';
$password = 'hotel_room1';
$url = 'http://127.0.0.1/cake2/rd_cake/permanent_users/add.json';
// The data to send to the API
$postData = array(
'active' => $active,
'cap_data' => $cap_data,
'language' => $language,
'parent_id' => $parent_id,
'profile_id' => $profile_id,
'realm_id' => $realm_id,
'token' => $token,
'username' => $username,
'password' => $password
);
// Setup cURL
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
// Check for errors
if($response === FALSE){
die(curl_error($ch));
}
// Decode the response
$responseData = json_decode($response, TRUE);
print_r($responseData);
?>