Exemple #1
0
        /// <summary>
        /// Gets all stream tags
        /// </summary>
        public async Task <TwitchStreamTags> GetAllStreamTags(
            string first         = null,
            string after         = null,
            List <string> tagIDs = null)
        {
            RestClient  restClient = new RestClient("https://api.twitch.tv/helix/tags/streams");
            RestRequest request    = new RestRequest(Method.GET);

            request.AddHeader("Client-ID", botConfig.TwitchClientId);

            request.AddOptionalParameter("first", first);
            request.AddOptionalParameter("tag_id", tagIDs);
            request.AddOptionalParameter("after", after);

            IRestResponse response = await restClient.ExecuteAsync(request);

            string jsonResponse = response.Content;

            jsonResponse = jsonResponse.Replace('-', '_');
            TwitchStreamTags info = JsonSerializer.Deserialize <TwitchStreamTags>(jsonResponse);

            //for (int i = 0; i < info.Data.Count; i++)
            //{
            //    info.Data[i].TagID = info.Data[i].TagID.Replace('_', '-');
            //}

            return(info);
        }
Exemple #2
0
        /// <summary>
        /// Gets stream tags for a specified broadcaster
        /// </summary>
        public async Task <TwitchStreamTags> GetStreamTags(string broadcasterId)
        {
            RestClient  restClient = new RestClient("https://api.twitch.tv/helix/streams/tags");
            RestRequest request    = new RestRequest(Method.GET);

            request.AddHeader("Client-ID", botConfig.TwitchClientId);

            request.AddParameter("broadcaster_id", broadcasterId);

            IRestResponse response = await restClient.ExecuteAsync(request);

            string jsonResponse = response.Content;

            jsonResponse = jsonResponse.Replace('-', '_');
            TwitchStreamTags info = JsonSerializer.Deserialize <TwitchStreamTags>(jsonResponse);

            //for (int i = 0; i < info.Data.Count; i++)
            //{
            //    info.Data[i].TagID = info.Data[i].TagID.Replace('_', '-');
            //}

            return(info);
        }