Come si alimenta il carico API API V3 su Windows Store C #
-
21-12-2019 - |
Domanda
Per mostrare un feed di notizie, musica, sport.Grazie.
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);
}
}
}
.
Sto usando:
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;
.
Errore: non trovare feed, richiesta ...
Soluzione
C'è usando 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 { }
}
. Altri suggerimenti
lê thiên houlng
Puoi provare ad usare il sindacatoFeed per aiutarti,
Controllare questo esempio, che utilizzando il progetto MyToolkit da implementare.
http://code.msdn.microsoft.com/WindowsApp / YouTube-Sample-get-youtube-e9a3e0be
E tu usi il metodo di feedurl è una vecchia API che è V2 non v3.
@ lê thiên houlng
Utilizzo http://gdata.youtube.com/demo/index.html per generare vuoi ottenere.
Se vuoi ottenere musica popolare, il tuo riposante collegamento API è: http://gdata.youtube.com/feeds/api/standardfeeds/ms_viewed/-/ {http://gdata.youtube.com/schemas/2007/Categorie.cat} Musica? Alt= RSS
Ma consiglio se è possibile, utilizzando YouTube API versione3, è migliore e più facile ottenere diversi video di categoria.
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();
}
}
.
ricevo questa fonte: Fonte: http://www.youtube.com/watch? v= _oblgsz8ssm & funzione= youtube_gdata
Ma non è giocare ...