显示新闻源,音乐,运动。谢谢。

 private void loadfeedYoutube()
    {
         string feedUrl="https://gdata.youtube.com/feeds/api/standardfeeds/most_popular";
         var request=new 
         Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));
         printVideoFeed(videoFeed);

            static void printVideoFeed(Feed<Video> feed)
            {
              foreach (Video entry in feed.Entries)
              {
                printVideoEntry(entry);
              }
            }
    }
.

我正在使用:

using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
.

错误:未找到源,请求...

有帮助吗?

解决方案

使用mytoolkit

  private void GetYoutubeChannel(string feedXML)
    {
        try
        {
            SyndicationFeed feed = new SyndicationFeed();
            feed.Load(feedXML);

            List<YoutubeVideo> videosList = new List<YoutubeVideo>();
            YoutubeVideo video;

            foreach (SyndicationItem item in feed.Items)
            {
                video = new YoutubeVideo();

                video.YoutubeLink = item.Links[0].Uri;
                string a = video.YoutubeLink.ToString().Remove(0, 31);
                video.Id = a.Substring(0, 11);
                video.Title = item.Title.Text;
                video.PubDate = item.PublishedDate.DateTime;

                video.Thumbnail = YouTube.GetThumbnailUri(video.Id, YouTubeThumbnailSize.Large);

                videosList.Add(video);
            }

            MainListBox.ItemsSource = videosList;
        }
        catch { }
    }
.

其他提示

lêthiênhoàng

您可以尝试使用SyndicationFeed来帮助您,

选中此示例,使用MyToolkit项目实现。

http://code.meb.microsoft.com/Windowsapps / YouTube-Sample-get-youtube-e9a3e0be

并且您使用Feedurel方法是旧API,其不是V3。

@lêthiênhoàng

使用 http://gdata.youtube.com/demo/index.html 生成你想要得到。

如果你想得到音乐流行,那么你的RESTFUL API链接是: http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed/-/// http://gdata.youtube.com/schemas/2007/categories.cat}音乐?Alt= RSS

但我建议您使用YouTube API Version3,更好,更轻松地获得不同的类别视频。

void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
    {
        try
        {
            DataModel.YoutubeVideo value = e.NavigationParameter as DataModel.YoutubeVideo;
            if(!string.IsNullOrWhiteSpace(value.id))
            {
                txttitle.Text = value.title;
                Mediaplayer.Source = value.youtubelink;
            }
        }
        catch
        {
            throw new NotImplementedException();
        }

    }
.

我收到这个来源:源: http://www.youtube.com/watch?v= _oblgsz8ssm&amp; feature= youtube_gdata

但它不玩...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top