如何循环 URL 并在 php 中传输数据
How to loop URL and stream data in php
您好,我正在尝试使用 php
发送服务器事件,我有一个 https url,我可以在每个操作中获取流数据。我需要 运行 一些我需要 24/7 获取数据流的脚本。
脚本应该运行一直在后台。
<?php
$ch = curl_init('https://api.abc.com:8100/update-stream/connect');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);
print_r($response);
?>
如何将此 curl
作为服务器发送事件,它总是 运行 并检查更新?
这东西可以帮到你。
<?php
header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("Connection: keep-alive");
while (true)
{
//your logic can go here
}
?>
您好,我正在尝试使用 php
发送服务器事件,我有一个 https url,我可以在每个操作中获取流数据。我需要 运行 一些我需要 24/7 获取数据流的脚本。
脚本应该运行一直在后台。
<?php
$ch = curl_init('https://api.abc.com:8100/update-stream/connect');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);
print_r($response);
?>
如何将此 curl
作为服务器发送事件,它总是 运行 并检查更新?
这东西可以帮到你。
<?php
header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("Connection: keep-alive");
while (true)
{
//your logic can go here
}
?>