can you fix this php file? it connects to websocket but doesn't output the full message with epg data
<?php
require __DIR__ . '/vendor/autoload.php';
use WebSocket\Client;
// IDs from your payload
$clientId = "7073e797-668c-4aa1-8f88-1211262bbdb6";
$sessionId = "c4777c8b-b9ed-4469-8ccc-3f8a002ec3e2";
$requestId = "b1817705-84c6-4838-be87-b8e039bdb6e2";
$serverId = "6f880509-76d7-4319-8602-0554177602ab";
// WebSocket URL
$wsUrl = "wss://ws.cms.jyxo.cz/websocket/$clientId/$sessionId";
$ws = new Client($wsUrl, [
'timeout' => 30,
'headers' => [
'Origin: https://www.oneplay.cz',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)...'
]
]);
// ✅ Send ConnectionInit to tell backend "I'm ready"
$ws->send(json_encode(["schema" => "ConnectionInit"]));
// Send HTTP POST to trigger EPG
$payload = [
"deviceInfo" => [
"deviceType" => "web",
"appVersion" => "1.3.11",
"deviceManufacturer" => "Unknown",
"deviceOs" => "Windows"
],
"capabilities" => ["async" => "websockets"],
"payload" => [
"criteria" => [
"channelSetId" => "channel_list.1",
"viewport" => [
"channelRange" => ["from" => 0, "to" => 20],
"timeRange" => [
"from" => "2025-07-11T22:00:00.000Z",
"to" => "2025-07-12T22:00:00.000Z"
],
"schema" => "EpgViewportAbsolute"
]
],
"requestedOutput" => [
"channelList" => "none",
"datePicker" => false,
"channelSets" => false
]
],
"context" => [
"requestId" => $requestId,
"clientId" => $clientId,
"sessionId" => $sessionId,
"serverId" => $serverId
]
];
$ch = curl_init('https://http.cms.jyxo.cz/api/v1.1/epg.display');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_exec($ch);
curl_close($ch);
// Listen for all messages
try {
while (true) {
$msg = $ws->receive();
$json = json_decode($msg, true);
if (json_last_error() === JSON_ERROR_NONE) {
echo json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
} else {
echo $msg . "\n";
}
}
} catch (Exception $e) {
echo "WebSocket error: " . $e->getMessage() . "\n";
}
?>