php和json解码链接停止工作

时间:2015-03-12 22:25:45

标签: php json php-curl

嗨我有一个小问题我需要帮助我有一个网页,以json格式输出实时流,链接看起来像这样

rtmp:\/\/server:port\/camera1.stream

现在如果我将该链接复制并通过记事本并将\/更改为/我自己,链接在我拥有的每个媒体播放器中都能正常播放,我可以看到相机提要但是当我使用php脚本解码json输出,当回显输出或添加到genarated m3u8文件时,流根本不播放:

bellow是我用来获取页面和json解码的代码

$stream_id = $_GET["cam"];
// create curl resource
$ch = curl_init();
//set url
curl_setopt($ch, CURLOPT_URL, "http://ip:port/json");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
//close curl resource to free up system resources
curl_close($ch);  
$response = json_decode($output), true);

foreach ($response['cameras'] as $result) {
    if($result['name'] == $stream_id){
        echo $result['cam_stream'];
    }
}

0 个答案:

没有答案