sheriff sheriff - 7 months ago 42
PHP Question

How to loop URL and stream data in php

Hi I'm trying server sent events using

, I have a https url where I get the stream data in every action. I need to run some scripts where I need to get a flow of data 24/7.

The script should run in background all the time.

$ch = curl_init('');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);

How can I make this
as a Server Sent Event, which always runs and checks for an updates?


This something can help you.

   header("Content-Type: text/event-stream");
   header("Cache-Control: no-cache");
   header("Connection: keep-alive");

   while (true)
        //your logic can go here