Wowza Cloud API:卷曲请求

时间:2017-10-27 09:00:23

标签: php curl wowza php-curl wowza-transcoder

我无法使它工作.. :(我有这个功能(用于创建直通代码转换器),当我运行时,我在网络上看到NULL。如果我直接从浏览器测试网址,它确实通知我auth(apikeyacceskey

存在问题
function createPassthrough($name, $source_url, $recording = null)
{
    $url = "https://sandbox.cloud.wowza.com/api/v1/transcoders";

    $json = '{
                "transcoder":{
                    "billing_mode":"pay_as_you_go",
                    "broadcast_location":"eu_belgium",
                    "delivery_method":"pull",
                    "name":"prueba",
                    "protocol":"rtsp",
                    "source_url":"url_camara",
                    "transcoder_Type":"passthrough",
                    "low_latency":true,
                    "buffer_size":0,
                    "play_maximum_connections":100,
                    "stream_smoother":false
                    }
            }';

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Accept:application/json; charset=utf-8',
        'Content-Type: application/json; charset=utf-8',
        'wsc-api-key:' . $apiKey,
        'wsc-access-key:' . $accessKey,
    ));

    $result = curl_exec($ch);
    curl_close($ch);

    $obj = json_decode($result);
    var_dump($obj);
}

我做错了什么?提前谢谢。

1 个答案:

答案 0 :(得分:0)

您应该在$result = curl_exec($ch);之后检查卷曲错误。

// Check for errors and display the error message
if($errno = curl_errno($ch)) {
    $error_message = curl_strerror($errno);
    echo "cURL error ({$errno}):\n {$error_message}";
}