Пример #1
0
        public async Task <List <string> > GetTrendingsURlsOfTheDay()
        {
            var giphy     = new Giphy(_apiKey);
            var gifResult = await giphy.TrendingGifs(new TrendingParameter());

            return(gifResult.Data.Select(data => data.Url).ToList());
        }
Пример #2
0
        static void Main(string[] args)
        {
            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddJsonFile(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\appsettings.json")), true, true)
                                           .Build();
            var apikey = configuration.GetSection("giphyapikey").Value;

            bool stayInSearch = true;
            var  giphy        = new Giphy(apikey, new MemoryCache(new MemoryCacheOptions()));

            while (stayInSearch)
            {
                Console.WriteLine("Please enter a word or words you want to search for gifs for: ");
                var searchQuery = Console.ReadLine();

                if (string.IsNullOrEmpty(searchQuery))
                {
                    continue;
                }
                // Returns gif results
                var gifs = giphy.GetOrCreateSearchResults(searchQuery);
                Console.WriteLine($"Following the search results for '{searchQuery}':\n\n");
                gifs.Wait();
                foreach (var url in gifs.Result)
                {
                    Console.WriteLine(url);
                }

                ConsoleKey response;
                do
                {
                    Console.Write("\n\nAre you want to keep searching for gifs ? [y/n]");
                    response = Console.ReadKey(false).Key;
                    if (response != ConsoleKey.Enter)
                    {
                        Console.WriteLine();
                    }
                } while (response != ConsoleKey.Y && response != ConsoleKey.N);

                stayInSearch = response == ConsoleKey.Y;
            }

            Console.WriteLine("\n\nPlease enter any key to get trending gifs\n\n");
            Console.ReadKey();
            Console.WriteLine($"Following the search results for trending gifs:\n\n");
            var trendingParameter = new TrendingParameter();
            var t2 = giphy.TrendingGifs(trendingParameter);

            t2.Wait();
            foreach (Data item in t2.Result.Data)
            {
                Console.WriteLine(item.EmbedUrl);
            }
            Console.ReadKey();
        }
Пример #3
0
        private void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            var trending = new TrendingParameter()
            {
                Limit = 1
            };

            m_giphy.TrendingGifs(trending).ContinueWith(task => {
                var results = task.Result.Data;
                Send(results[0].Images.Original.Url);
            });
        }
Пример #4
0
 public async void TrendingTest()
 {
     var result = await _giphy.TrendingGifs(new TrendingParameter());
 }