2013-04-29 123 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“);

相关问题