加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

Youtube API下载标题(使用PHP示例)

发布时间:2020-12-13 16:10:02 所属栏目:PHP教程 来源:网络整理
导读:我在 Youtube Data API – Captions: download工作,使用PHP示例 我可以成功获得成绩单清单, 但无法下载成绩单. 输入字幕轨道ID并点击GO后,它会中断页面??. 如果我在没有CC贡献的情况下尝试来自视频的曲目ID,我会得到正确的错误: A service error occurred:
我在 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().

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读