1

I am attempting to create the backend of a Twitch Extension that will search for all other users streaming the same game. The only way to get the Category with which to compare games is if the channel in question is live. This is fine, as the extension should will only be working whenever the stream goes live.

My issue is that I do not know how I can determine whether or not the user of the extension has gone online.

    public static async Task<string> GetStreamAsync()
    {
        string product = "";
        List<Stream> finalProduct = new List<Stream>();

        var response = await _httpClient.GetAsync("https://api.twitch.tv/helix/streams?user_login=Ninja");
        if (response.IsSuccessStatusCode)
        {
            product = await response.Content.ReadAsStringAsync();
            var streamToRelate = JsonConvert.DeserializeObject<RootStream>(product);

            finalProduct = await GetAllRelatedChannels(streamToRelate.Data.FirstOrDefault());
        }

        return product;
    }

As you can see, I've hard coded a stream that I knew was online at the time (Ninja). This data was returned perfectly fine, but the next step is to pass a string into this function with which to search. How could I go about getting the "User" of the extension at runtime? If I am completely off-base, and am missing certain concepts, please let me know as well and I will do further research if necessary.

Clavaat
  • 67
  • 1
  • 10
  • So you want to show other streamers playing the same game (product) as you if you're the logged in user as detected by the extension? You'll prob need to do something like https://stackoverflow.com/questions/25251377/get-username-from-twitch-api-using-authorization-code-flow-php – mjw Jul 29 '19 at 20:50
  • No, I'm asking how do I know "detect" or "see" what the "current user" is when they start streaming. Instead of using hard-coded names, the next step is to accept "current user" and I don't know how to do that. – Clavaat Jul 29 '19 at 20:54
  • Hi @Clavaat. Are you still having an issue with this? From what I understand you're trying to get the userid/username of the broadcaster that is currently using the extension? – Tristan Aug 16 '19 at 22:43
  • I am still having this issue, and that is correct. – Clavaat Aug 20 '19 at 02:52
  • Well if you already know that they've started streaming then you can call the `/users` endpoint with no params and it'll return you a collection of 1 containing just the auth'ed user. That'll give you their userId and then you can get the rest from there. – JBC Aug 22 '19 at 17:19

0 Answers0