$operator, "value" => $value, "property" => $filter ]]; $encoded_filter = urlencode(json_encode($filter_array)); $find_url = "$server/cake4/rd_cake/permanent-users/index.json?page=1&start=0&limit=1000&filter=$encoded_filter&token=$token&cloud_id=$cloud_id"; // Get User IDs $listOfIds = getIds($find_url); if ($listOfIds) { foreach ($listOfIds as $id) { $payload = [ 'cloud_id' => $cloud_id, 'token' => $token, 'realm' => $realm, 'profile' => $profile, 'id' => $id ]; $response = sendPostRequest($api_url, $payload); echo "Updated ID $id - Response: $response\n"; } } function getIds($find_url) { $context = stream_context_create([ 'http' => [ 'header' => "Accept: application/json\r\nContent-Type: application/json\r\n" ] ]); echo "Fetching URL: $find_url\n"; $response = file_get_contents($find_url, false, $context); if ($response === false) { echo "Error fetching data\n"; return false; } $data = json_decode($response, true); if (!empty($data['items']) && is_array($data['items'])) { echo "There are " . count($data['items']) . " items\n"; return array_column($data['items'], 'id'); } echo "No items found.\n"; return false; } function sendPostRequest($url, $data) { $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_HTTPHEADER => ['Content-Type: application/json'] ]); $response = curl_exec($ch); if ($response === false) { echo "cURL error: " . curl_error($ch) . "\n"; } curl_close($ch); return $response; } ?>