1

I am trying to make a live video event on bright cove site through my application made using PHP now according to their docs I have POSTED my request to their server using cURL and getting the success response. I have used the following the cURL command to send my request.

function createLiveEvent() {
$api = $_POST['api_key'];
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.bcovlive.io/v1/jobs");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{"
        . "\n    \"live_stream\": true,"
        . "\n    \"region\": \"us-west-2\","
        . "\n    \"reconnect_time\": 1800,"
        . "\n    \"live_sliding_window_duration\": 57600,"
        . "\n    \"outputs\": ["
        . "\n        {"
        . "\n            \"label\": \"hls720p\","
        . "\n            \"live_stream\": true,"
        . "\n            \"width\": 1280,"
        . "\n            \"height\": 720,"
        . "\n            \"video_codec\": \"h264\","
        . "\n            \"h264_profile\": \"high\","
        . "\n            \"video_bitrate\": 2100,"
        . "\n            \"segment_seconds\": 4,"
        . "\n            \"keyframe_interval\": 60\n        },"
        . "\n        {\n            \"label\": \"hls540p\","
        . "\n            \"live_stream\": true,"
        . "\n            \"width\": 960,\n            \"height\": 540,"
        . "\n            \"video_codec\": \"h264\","
        . "\n            \"h264_profile\": \"main\","
        . "\n            \"video_bitrate\": 1500,"
        . "\n            \"segment_seconds\": 4,"
        . "\n            \"keyframe_interval\": 60\n        },"
        . "\n        {\n            \"label\": \"hls360p\","
        . "\n            \"live_stream\": true,\n            \"width\": 640,"
        . "\n            \"height\": 360,\n            \"video_codec\": \"h264\","
        . "\n            \"h264_profile\": \"main\","
        . "\n            \"video_bitrate\": 800,"
        . "\n            \"segment_seconds\": 4,"
        . "\n            \"keyframe_interval\": 60\n        }\n    ]\n}\n");
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Cache-Control: no-cache";
$headers[] = "Content-Type: application/json";
$headers[] = "Postman-Token: postman_token";
$headers[] = "X-Api-Key: " . $api;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

wp_send_json($result);
}

And I am getting my response but I can't see my live event in my account on bright cove. I am sort of stuck at this point that what is it that I am missing here or doing wrong.

Mohsin Abbas
  • 630
  • 8
  • 29
  • Don't build json yourself. It's a very bad idea (and easy to mess up). Create an array with the correct structure and use [json_encode()](http://php.net/manual/en/function.json-encode.php) to convert it to a json string. – M. Eriksson Jan 30 '18 at 05:35
  • Yes sir I will go that way it's just like I am testing it right now my local server but before pushing it live I will use the same way you told me but the issue is my event is not creating on the bright cove site – Mohsin Abbas Jan 30 '18 at 05:40
  • There is event gallery template available in brightcove where you can livestream an event. – bhansa Jan 31 '18 at 17:24
  • I can't see my event created even there as well – Mohsin Abbas Feb 01 '18 at 05:56

0 Answers0