2017-08-30 102 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')); 

希望這有助於。