2013-04-29 121 views
1

我目前正在探索使用Google的YouTube API從YouTube頻道檢索觀看次數(Google.Apis.Youtube.v3.dll)。我可以成功檢索關於頻道中的視頻的信息,但無法檢索實際的觀看次數。如何從YouTube API檢索視頻觀看次數

實施例:

foreach (var channel in channelsListResponse.Items) 
    { 
    var viewcount = channel.Statistics.ViewCount; 

我不斷收到錯誤的「未設置爲一個對象的實例對象引用」。

是否有人有.net代碼示例使用YouTube API檢索視圖計數或知道可能導致此類錯誤的原因?

回答

0

這對你有幫助嗎?它檢索用戶配置文件的所有信息https://developers.google.com/youtube/2.0/developers_guide_dotnet#Retrieving_a_User_Profile

+0

我確定我可以像在示例中那樣獲得調用網址的查看次數。我正在使用Oauth2身份驗證和最新的YT(V3)API,我相信我不必明確指定url..user ....我應該能夠獲得通道中每個視頻的視圖計數這個問題。現在我能夠得到一個標題,描述.... – user1526912 2013-04-29 19:29:33

0

使用DotNetOpenAuth.OAuth2;

使用Google.Apis.Authentication; 使用Google.Apis.Authentication.OAuth2; 使用Google.Apis.Authentication.OAuth2.DotNetOpenAuth; 使用Google.Apis.Samples.Helper;使用Google.Apis.Services的 ; 使用Google.Apis.Util; 使用Google.Apis.Youtube.v3; 使用Google.Apis.Youtube.v3.Data;

變種的YouTube =新YoutubeService(新BaseClientService.Initializer() { 身份驗證= AUTH });

var viewcount = youtube.Videos.List(「enter video ID here,」statistics「);

相關問題