我注意到我的 Youtube 数据 API v3 请求的搜索响应明显错误。如果您打开以下搜索示例的视频,您可以找到所属的 YT 频道“What If”,并且在此频道的“关于”部分中,区域设置为“美国”而不是“德国”,区域代码 = '德'。我的查询有什么问题吗?
如何在响应片段中获取附加相关数据作为我的搜索查询的“相关语言”和“配额成本”?
//PHP code not written here to build a valid youtube data api request like
$youtube = new Google_Service_YouTube($client);
$search_params= array(
'maxResults' => 1,
'order' => 'viewCount',
'q' => 'surfing',
'type' => 'video',
'relevanceLanguage' => 'de',
'regionCode' => 'DE',
'videoCategoryId' => '28',
)
$query_response = $youtube->search->listSearch('snippet', $search_params);
//$query_response contains:
array (
'etag' => 'TT_NHP87XlwK-pn_oASDgmdJC1M',
'eventId' => NULL,
'kind' => 'youtube#searchListResponse',
'nextPageToken' => 'CAEQAA',
'prevPageToken' => NULL,
'regionCode' => 'DE',
'visitorId' => NULL,
'pageInfo' =>
array (
'resultsPerPage' => 1,
'totalResults' => 1000000,
),
'items' =>
array (
0 =>
array (
'etag' => '-qHAyLT6BU32OwuPOZpSRgaVzIE',
'kind' => 'youtube#searchResult',
'id' =>
array (
'channelId' => NULL,
'kind' => 'youtube#video',
'playlistId' => NULL,
'videoId' => 'dVr3m9S0cEk',
),
'snippet' =>
array (
'channelId' => 'UCphTF9wHwhCt-BzIq-s4V-g',
'channelTitle' => 'What If',
'description' => 'Is surfing a tsunami even possible? And have people done this before? Thanks, Audible! Start listening with a 30-day trial and ...',
'liveBroadcastContent' => 'none',
'publishedAt' => '2019-08-19T16:55:56Z',
'title' => 'What If You Tried to Surf a Tsunami?',
'thumbnails' =>
array (
'default' =>
array (
'height' => 90,
'url' => 'https://i.ytimg.com/vi/dVr3m9S0cEk/default.jpg',
'width' => 120,
),
'medium' =>
array (
'height' => 180,
'url' => 'https://i.ytimg.com/vi/dVr3m9S0cEk/mqdefault.jpg',
'width' => 320,
),
'high' =>
array (
'height' => 360,
'url' => 'https://i.ytimg.com/vi/dVr3m9S0cEk/hqdefault.jpg',
'width' => 480,
),
),
),
),
),
)
我在网上爬了几个小时,但没有找到任何答案来回答我的问题。有谁知道吗
在 Google/Youtube 文档中:
regionCode string,regionCode参数指示API返回指定国家/地区可以观看的视频的搜索结果。
relevanceLanguage 字符串,relevanceLanguage 参数指示 API 返回与指定语言最相关的搜索结果...请注意,如果其他语言的结果与搜索查询词高度相关,仍然会返回。
因此,“relevanceLanguage”似乎并不排除与请求主题相关的其他语言,regionCode 仅检查视频是否可以在该地区观看,并且配额费用似乎无法访问。
所以 Youtube 数据 API 让我找不到我正在寻找的视频。