Solved Twitch API

Discussion in 'Plugin Development' started by blm456, Dec 10, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    blm456

    So I'm trying to get the JSON file that the Twitch API provides from apt.twitch.tv/kraken/atreams/(Streamername) and put that into a File Object. any help?

    Code:
    try{
                URL url = new URL("http://api.twitch.tv/kraken/streams/" + streamname);
               
                JSONParser par = new JSONParser();
               
                File f = new File(url.getFile());
                JSONArray obj = (JSONArray) par.parse(new FileReader(f));
                for(Object o : obj){
                    JSONObject ob = (JSONObject) o;
                    Object stream = ob.get("Stream");
                   
                    System.out.println(stream + "");
                }
               
            }catch(Exception e){
                e.printStackTrace();
            }
     
  2. Offline

    Skionz

  3. Offline

    blm456

    Skionz likes this.
Thread Status:
Not open for further replies.

Share This Page