2017-08-30 84 views
0

当频道上线时,是否可以从YouTube获取某种标志?直播视频信息

例如,当YouTube频道开始直播时,我需要能够获取该信息并使用它。 这可能吗?

回答

0

您可以使用search.list,然后将eventType参数设置为live

https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCXswCcAMb5bvEUIDEzXFGYg&type=video&eventType=live&key=[API_KEY] 

的示例代码段:

// Sample php code for search.list 

function searchListLiveEvents($service, $part, $params) { 
    $params = array_filter($params); 
    $response = $service->search->listSearch(
     $part, 
     $params 
    ); 

    print_r($response); 
} 

searchListLiveEvents($service, 
    'snippet', 
    array('eventType' => 'live', 'maxResults' => 25, 'q' => 'news', 'type' => 'video')); 

希望这有助于。