示例#1
0
        async static void Example()
        {
            //getting country of user
            string name         = RegionInfo.CurrentRegion.EnglishName;
            var    analysedtext = await RazerApi.AnalyseText(File.ReadAllText("test.txt"));

            var auth = new ImplicitGrantAuth(
                "7f08980f1dae4f3d98a40d44ef235b03",
                "http://localhost:4002",
                "http://localhost:4002",
                Scope.UserReadPrivate
                );

            auth.AuthReceived += async(sender, payload) =>
            {
                auth.Stop(); // `sender` is also the auth instance
                var api = new SpotifyWebAPI()
                {
                    TokenType   = payload.TokenType,
                    AccessToken = payload.AccessToken
                };
                // FeaturedPlaylists playlists = api.GetFeaturedPlaylists();
                //Console.WriteLine(playlists.Message);
                //playlists.Playlists.Items.ForEach(playlist => Console.WriteLine(playlist.Name));

                //getting playlists from categories and outputting names and links of the playlist.
                CategoryPlaylist playlists = api.GetCategoryPlaylists("party");
                playlists.Playlists.Items.ForEach(playlist => Console.WriteLine("Playlist Name: " + playlist.Name + ",\nLink: " + playlist.Uri));

                // Do requests with API client
                var newsapiresults = await NewsApi.SearchByKeyword("bitcoin", name);

                if (newsapiresults == null)
                {
                    return;
                }
                Debug.WriteLine(newsapiresults);
                Debug.WriteLine(newsapiresults.totalResults);
                foreach (var result in newsapiresults.articles)
                {
                    //Console.WriteLine();
                    Debug.WriteLine(result.title);
                }


                var spotifyresults = await api.SearchItemsAsync("drake", SearchType.All);

                if (spotifyresults == null)
                {
                    return;
                }

                Console.WriteLine(spotifyresults);
            };

            auth.Start(); // Starts an internal HTTP Server
            auth.OpenBrowser();
        }
示例#2
0
        private async void DisplayNewsAPIResults(string keyword)
        {
            var results = await NewsApi.SearchByKeyword(keyword, Region);

            lvArticles.ItemsSource = results.articles.GroupBy(a => a.title).Take(10);

            /*for (int i = 0; i < results.articles.Count && i < 10; i++)
             * {
             *  //var article = results.articles[i];
             *  //listView.Items.Add(article);
             *
             *
             *  //cmbNewsResults.Items.Add(article.title);
             * }*/
        }