Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube Live Broadcast API: liveStreamingNotEnabled

Using the Youtube API via PHP to create events on users accounts who are authorised by OAuth. The code works for almost everybody except I have a couple of users who are getting the liveStreamingNotEnabled error as detailed here https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/insert. Obviously I assumed live streaming isn't enabled on their account so ask them if their account is verified, in good standing and if it shows as enabled on https://www.youtube.com/features which ususally points them in the right direction to getting it fixed.

However I have just been given access to a users account who is verified, in good standing and the YT features page shows his account as Live Streaming enabled as shown here enter image description here

Whats even more confusing is that I can create and start a live broadcast manually from inside his account.

Any ideas what could be causing this? Driving me crazy!

like image 421
KyleC Avatar asked Nov 09 '16 12:11

KyleC


People also ask

Does YouTube TV have an API?

You can use the YouTube Data API to update metadata about the video, such as the recording location or the regions where the broadcast will be viewable. Defines the advertising settings for a video (or broadcast). You use the YouTube Content ID API to set advertising options.


1 Answers

This is not necessarily an answer to the question but rather a workaround. However, I hope people find it useful when dealing with this problem until a real answer or solution is found.

Seems like the PHP client library has some kind of bug and it throws this liveStreamingNotEnabled error we are talking about. However, it works perfectly when using the cURL approach like this:

$endpoint = 'https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet,contentDetails,status&broadcastType=all&mine=true&key=[YOUR_API_KEY]';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Accept: application/json',
    'Authorization: Bearer '.$_SESSION['access_token'] // make sure this exists
]);
$output = curl_exec($ch);
curl_close($ch);
$res = json_decode($output, true);
if(isset($res['error'])){
    throw new Google_Exception($res['error']['message']);
}

So, I hope it really is just a simple bug in the library that just has not been addressed in a really long time. I posted the issue on GitHub.

like image 185
Zeke Avatar answered Oct 17 '22 14:10

Zeke