Exemplo n.º 1
0
        protected void webserviceCall()
        {
            HttpWebRequest request = WebRequest.Create("https://api.twitch.tv/kraken/streams") as HttpWebRequest;
            StreamReader   reader;
            String         Topcontent;

            // Get response
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                // Get the response stream
                reader = new StreamReader(response.GetResponseStream());

                //save string response so we can cut it up
                Topcontent = reader.ReadToEnd();
            }

            //pull top out of string and turn into jobjects
            var jsonData = JObject.Parse(Topcontent)["streams"];



            foreach (JObject name in jsonData)
            {
                TopStreamsResult tempObject = new TopStreamsResult();
                //pull games array out and save in a secondary list
                tempObject.gameName     = (name["channel"]["game"].ToString());
                tempObject.displayName  = (name["channel"]["display_name"].ToString());
                tempObject.streamStatus = (name["channel"]["status"].ToString());
                tempObject.streamlogo   = (name["channel"]["profile_banner"].ToString());
                listofTopStreams.Add(tempObject);
            }
            //test print
            foreach (TopStreamsResult topGame in listofTopStreams)
            {
                Debug.WriteLine("DISPLAY NAME: " + topGame.displayName + " GAME NAME: " + topGame.gameName + " STREAM STATUS: " + topGame.streamStatus);
            }
        }
        protected void webserviceCall()
        {
            HttpWebRequest request = WebRequest.Create("https://api.twitch.tv/kraken/streams") as HttpWebRequest;
            StreamReader reader;
            String Topcontent;

            // Get response
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                // Get the response stream
                reader = new StreamReader(response.GetResponseStream());

                //save string response so we can cut it up
                Topcontent = reader.ReadToEnd();

            }

            //pull top out of string and turn into jobjects
               var jsonData = JObject.Parse(Topcontent)["streams"];

            foreach (JObject name in jsonData)
            {
                TopStreamsResult tempObject = new TopStreamsResult();
                //pull games array out and save in a secondary list
                tempObject.gameName = (name["channel"]["game"].ToString());
                tempObject.displayName = (name["channel"]["display_name"].ToString());
                tempObject.streamStatus = (name["channel"]["status"].ToString());
                tempObject.streamlogo = (name["channel"]["profile_banner"].ToString());
                listofTopStreams.Add(tempObject);

            }
            //test print
            foreach (TopStreamsResult topGame in listofTopStreams)
            {
                Debug.WriteLine("DISPLAY NAME: " + topGame.displayName + " GAME NAME: " + topGame.gameName + " STREAM STATUS: " + topGame.streamStatus);
            }
        }