您可以使用以下代码来获取"now_play": 1数组内的"m3u8"地址:

<?php

$url = "https://mapi.ngcz.tv/api/v1/program.php?&zone=0&channel_id=30";
$data = file_get_contents($url);
$array = json_decode($data, true);

foreach ($array as $item) {
    if ($item['now_play'] == 1) {
        $m3u8Url = $item['channel_stream'][0]['m3u8'];
        echo $m3u8Url;
        break;
    }
}
?>

这段代码首先使用file_get_contents()函数从给定的URL获取数据,并将其解析为一个关联数组。然后,使用foreach循环遍历数组中的每个项目。在循环中,检查当前项目的"now_play"值是否为1。如果是,获取"m3u8"地址并打印出来。最后,使用break语句来跳出循环,因为您只需要获取第一个满足条件的项目

请求httpsmapingcztvapiv1programphp&zone=0&channel_id=30得到	id 1693498140	channel_id 30	schedule_id 0	record_id 0	index_pic 	start_time 1693498140	date 2023-09-01	create_user_id 40	create_user_name 谷永发	cr

原文地址: https://www.cveoy.top/t/topic/iVKO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录