I'm working from Youtube Data API - Captions: download, Using the PHP example
I can get the list of transcripts successfully,
but cannot download the transcript.
After entering caption track ID and hitting GO, it breaks the page.
If I try a track ID from a video without CC contributions allowed, I get the correct error of:
A service error occurred: The permissions associated with the request are not sufficient to download the caption track. The request might not be properly authorized, or the video order might not have enabled third-party contributions for this caption.
I've tried excluding the second optional parameter on $youtube->captions->download, with no luck.
It breaks when it tries to print $captionResource (I'm new to debugging PHP)
//(original from Youtube API examples)
function downloadCaption(Google_Service_YouTube $youtube, $captionId, &$htmlBody) {
// Call the YouTube Data API's captions.download method to download an existing caption.
$captionResouce = $youtube->captions->download($captionId, array(
'tfmt' => "srt",
'alt' => "media"
));
$htmlBody .= "<h2>Downloaded caption track</h2><ul>";
$htmlBody .= sprintf('<li>%s</li>',
$captionResouce);
$htmlBody .= '</ul>';
}
Instead of $captionResource
try $captionResource->getBody()->getContents()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With