@שמואל-ש הקוד עובד מצוין והראיה שדרך הדפדפן הוא עובד לכן השאלה היא על השלוחה בכל אופן הנה הקוד
<?php
// Get the parameters from the URL
$token = $_GET['token'];
$queuePath = $_GET['queuePath'];
$moreData = isset($_GET['moreData']) ? $_GET['moreData'] : null;
// Check if the token is provided
if (empty($token)) {
die('Error: Token parameter is missing.');
}
// API endpoint URL for the first request
$apiEndpoint = 'https://private.call2all.co.il/ym/api/GetQueueRealTime';
// Prepare data for the first request
$data = array(
'token' => $token,
'queuePath' => $queuePath,
);
// Initialize cURL session for the first request
$ch = curl_init();
// Set cURL options for the first request
curl_setopt($ch, CURLOPT_URL, $apiEndpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
// Execute cURL session and get the response for the first request
$response = curl_exec($ch);
// Check for cURL errors
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
// Close cURL session for the first request
curl_close($ch);
// Decode the JSON response from the first request
$decodedResponse = json_decode($response, true);
// Check if the 'entries' parameter exists in the response
if (isset($decodedResponse['entries']) && !empty($decodedResponse['entries'])) {
// Extract all CallId values from the 'entries' array
$callIds = array_map(function ($entry) {
return $entry['CallId'];
}, $decodedResponse['entries']);
// API endpoint URL for the second request
$secondApiEndpoint = 'https://private.call2all.co.il/ym/api/QueueManagement';
// Prepare data for the second request
$secondData = array(
'token' => $token,
'callIds' => $callIds,
'action' => 'kick',
'moreData' => $moreData,
'queuePath' => $queuePath
);
// Initialize cURL session for the second request
$secondCh = curl_init();
// Set cURL options for the second request
curl_setopt($secondCh, CURLOPT_URL, $secondApiEndpoint);
curl_setopt($secondCh, CURLOPT_RETURNTRANSFER, true);
curl_setopt($secondCh, CURLOPT_POST, true);
curl_setopt($secondCh, CURLOPT_POSTFIELDS, json_encode($secondData));
curl_setopt($secondCh, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
// Execute cURL session and get the response for the second request
$secondResponse = curl_exec($secondCh);
// Check for cURL errors in the second request
if (curl_errno($secondCh)) {
echo 'Curl error: ' . curl_error($secondCh);
}
// Close cURL session for the second request
curl_close($secondCh);
// Output the response from the second API
echo $secondResponse;
} else {
echo 'Error: No entries found in the response from the first API.';
}