我在
Youtube Data API – Captions: download工作,使用PHP示例
我可以成功获得成绩单清单,
但无法下载成绩单.
输入字幕轨道ID并点击GO后,它会中断页面.
如果我在没有CC贡献的情况下尝试来自视频的曲目ID,我会得到正确的错误:
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.
我已经尝试在$youtube-> captions->下载中排除第二个可选参数,但没有运气.
当它试图打印$captionResource时它会中断(我是调试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>';
}
最佳答案 而不是$captionResource尝试$captionResource-> getBody() – > getContents().