示例#1
0
        public static void Main()
        {
            TeamWorkAPI teamWorkAPI             = new TeamWorkAPI(new APISettings(File.ReadAllText("apikey.txt")));
            ListLatestArticlesResponse response = teamWorkAPI.News.ListLatestArticles();

            foreach (NewsPost post in response.News)
            {
                Console.WriteLine($"{post.Title}  (@{post.CreatedAtInfo.Date})");
                Console.WriteLine(post.Hash);
            }

            Console.WriteLine("\n=== Getting a news post ===\n");

            //Get a news article
            NewsPost newsPost = teamWorkAPI.News.GetSpecificArticle("a60761dd5cf0ad6922fecb1ef0e3250d");

            Console.WriteLine(newsPost.Title);

            Console.WriteLine("\n=== Getting a YouTuber ===\n");

            //Get a YouTuber
            YouTuber[] youTuber = teamWorkAPI.Creators.GetYoutuber("76561198072335402");
            foreach (YouTuber item in youTuber)
            {
                Console.WriteLine($"{item.Name} ({item.YouTubeAccount})");
            }

            Console.ReadKey();
        }
示例#2
0
        /// <summary>
        /// Get an overview of the last 20 news items posted
        /// <para>All these news items are also displayed on the site at news</para>
        /// </summary>
        /// <exception cref="Exception">Occurs when the Json deserialization fails.</exception>
        public ListLatestArticlesResponse ListLatestArticles()
        {
            //Get a response from the server
            string jsonResult = client.GetJsonData(ArticlesApiEndpoint);

            try
            {
                List <NewsPost> searchResponse =
                    JsonConvert.DeserializeObject <List <NewsPost> >(jsonResult);

                ListLatestArticlesResponse response = new ListLatestArticlesResponse(searchResponse);

                return(response);
            }
            catch (JsonSerializationException)
            {
                throw new Exception("Json deserialization failed! This could be because of malformed data or the API key is incorrect!");
            }
        }