$operator, "value" => $value, // this stays a boolean! "property" => $filter ] ]; $encoded_filter = urlencode(json_encode($filter_array)); $find_url = "$server/cake4/rd_cake/permanent-users/index.json?page=1&start=0&limit=$limit&filter=$encoded_filter&token=$token&cloud_id=$cloud_id"; $listOfIds = getIds(); if($listOfIds){ $listOfIds['cloud_id'] = $cloud_id; $listOfIds['token'] = $token; $listOfIds['rb'] = $action; $json_payload = json_encode($listOfIds); $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 "Response: $response\n"; } function getIds(){ global $find_url; // Create stream context with headers $context = stream_context_create([ 'http' => [ 'header' => "Accept: application/json\r\n" . "Content-Type: application/json\r\n" ] ]); print($find_url); // Get the response $response = file_get_contents($find_url, false, $context); if ($response === false) { echo "Error fetching data"; exit; } // Decode JSON $data = json_decode($response, true); if (!empty($data['items']) && is_array($data['items'])) { $count = count($data['items']); $listOfIds = []; foreach($data['items'] as $permanentUser){ $id = $permanentUser['id']; $listOfIds[$id] = $id; } echo "There $count items\n"; return $listOfIds; } else { echo "No items."; } return false; } ?>