I am very new to programming, I have achieved it relatively easily (thanks to multiple and clear examples on the internet) read the response of dtweet and save it in a variable.
This is the code I have:
package leerrespuestadedweet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
public class LeerRespuestaDeDweet {
public static void main(String[] args) {
try {
String lineaDeDweet, mensajeDeDweet = "";
URL verDweet = new URL("https://dweet.io/get/latest/dweet/for/my-thing-name");
try (BufferedReader entradaDweet = new BufferedReader(new InputStreamReader(verDweet.openStream()))) {
while ((lineaDeDweet = entradaDweet.readLine()) != null){mensajeDeDweet += lineaDeDweet;}
entradaDweet.close();
System.out.println(mensajeDeDweet);
} catch (IOException ex) {
Logger.getLogger(LeerRespuestaDeDweet.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (MalformedURLException ex) {
Logger.getLogger(LeerRespuestaDeDweet.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
I want to do the same within a web page and I thought it would be possible with JavaScript (I know it has nothing to do with Java). Probably it is simple or it must be done directly in HTML ...
On the internet I can not find anything. Any example? Any link that you know and can help me?
Thank you for your patience.