2015-12-21 86 views

回答

1

在YouTube Analytics(分析)API的Sample Application

var request = gapi.client.youtubeAnalytics.reports.query({ 
    // The start-date and end-date parameters must be YYYY-MM-DD strings. 
    'start-date': formatDateString(lastMonth), 
    'end-date': formatDateString(today), 
    // At this time, you need to explicitly specify channel==channelId. 
    // See https://developers.google.com/youtube/analytics/v1/#ids 
    ids: 'channel==' + channelId, 
    dimensions: 'day', 
    sort: 'day', 
    // See https://developers.google.com/youtube/analytics/v1/available_reports 
    // for details about the different filters and metrics you can request 
    // if the "dimensions" parameter value is "day". 
    metrics: 'averageViewDuration', 
    filters: 'video==' + videoId 
    }); 

當然,這是假設你已經做了驗證和rettrieving的VideoID的工作稍加修改的平均觀看時間。