0

I can't make it work.. :( I have this function (for create passthrough transcoder), when I run I see NULL in the web. If I test directly from the browser with the url, it does notify me that there is a problem an auth (apikey and acceskey)

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);
}

What am I doing wrong? Thanks in advance.

Xpleria
  • 5,472
  • 5
  • 52
  • 66

1 Answers1

0

You should check for curl errors after $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}";
}
Iurii Drozdov
  • 1,685
  • 1
  • 12
  • 23
  • Thanks u! I have tried and it shows the error that I don't understand: cURL error (60): Peer certificate can not be authenticated with given CA certificates What can be? – Moisés Castell Alcaraz Oct 27 '17 at 09:13
  • You need to add these curl options curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); – Iurii Drozdov Oct 27 '17 at 09:15
  • please do var_dump of your $apiKey and $accessKey. You should declare them as input params of your function or give a value to them inside the function . – Iurii Drozdov Oct 27 '17 at 09:19
  • Yes! I had already find at the error, and as you say. Now it works. Thank you very much! https://stackoverflow.com/questions/18971983/curl-requires-curlopt-ssl-verifypeer-false – Moisés Castell Alcaraz Oct 27 '17 at 09:22
  • Yes, I noticed and modified it: 'wsc-api-key:'. $this-> apiKey, 'wsc-access-key:'. $this-> accessKey, Thx! – Moisés Castell Alcaraz Oct 27 '17 at 09:23