【问题标题】:how to get contentDetails part from youtube video list如何从 youtube 视频列表中获取 contentDetails 部分
【发布时间】:2015-04-29 06:28:54
【问题描述】:

我正在开发 youtube api v3,并希望在列表中显示每个视频的持续时间。 这是我的代码,但是当我运行此代码时,它给了我错误

“致命错误:未捕获的异常 'Exception' 带有消息 'Error 400 contentDetails : unknownPart' 在 /home/whatcove/public_html/youtube/youtube_v3/yt/vendor/madcoda/php-youtube-api/lib/Madcoda/Youtube.php:364 堆栈跟踪:#0 /home/whatcove/public_html/youtube/youtube_v3/yt/vendor/madcoda/php-youtube-api/lib/Madcoda/Youtube.php(145): Madcoda\Youtube->decodeList('{\n "error": {\n ...') #1 /home/whatcove/public_html/youtube/youtube_v3/yt/vendor/madcoda/php-youtube-api/lib/Madcoda/Youtube.php(77): Madcoda\Youtube->searchAdvanced(Array) #2 /home/whatcove/public_html/youtube/youtube_v3/yt/index.php(12): Madcoda\Youtube->search('leela movie') #3 {main} 投入 /home/whatcove/public_html/youtube/youtube_v3/yt/vendor/madcoda/php-youtube-api/lib/Madcoda/Youtube.php 在线 364"

    public function search($q, $maxResults = 10)
{
    $params = array(
        'q' => $q,
        'part' => 'id, snippet, contentDetails',
        'maxResults' => $maxResults
    );
    return $this->searchAdvanced($params);
}

【问题讨论】:

    标签: youtube youtube-api youtube-data-api


    【解决方案1】:

    “搜索”端点没有 contentDetails 部分;您也不能从“搜索”端点检索视频时长。 Rather, it's used to get minimal information (think of the metaphor of search results) and offer the most possible filters, and then when a video is selected, you can use the videoId to hit the 'videos' endpoint (where you have much more信息返回但不太可能的过滤器,所以它真的不能用于搜索)。

    【讨论】:

      猜你喜欢
      • 2015-08-31
      • 2015-12-07
      • 2017-08-25
      • 2012-10-24
      • 2021-12-19
      • 2012-12-26
      • 2017-06-09
      • 1970-01-01
      • 2020-06-03
      相关资源
      最近更新 更多