Youtube API v3 - Get "Live Now" rtmp and streamkey
The default broadcast can be retrieved by livebroadcasts.list with broadcastType set to "persistent".
The default livestream can be retrieved by livestreams.list using boundstreamid.
You cannot retrieve "Live Now" ingestion info because the API does not differentiate between "Live Now" and "Events." Those two options are provided as interfaces on top of the API for an end user, so they don't have to write their own application that interfaces with the API.
You will have to manually set up liveBroadcast
and liveStream
objects, bind them with liveBroadcasts.bind
, test your stream, and transition to live on the liveStream
object using status.streamStatus
.
To Get “Live Now” rtmp and streamkey
$broadcastsResponse = $youtube->liveBroadcasts->listLiveBroadcasts(
'id,snippet,contentDetails',
array(
'broadcastType' => 'persistent',
'mine' => 'true',
));
$boundStreamId = $broadcastsResponse['items']['0']['contentDetails']['boundStreamId'];
$streamsResponse = $youtube->liveStreams->listLiveStreams('id,snippet,cdn', array(
// 'mine' => 'true',
'id' => $boundStreamId
));
print_r($streamsResponse);