開始時刻と終了時刻を入力する必要があり、Swing Java でさらに URL に送信して、今回GET REST
呼び出しを使用して作成された選択されたノードをいくつか取得します。
URL
は:
http://wisekar.iitd.ernet.in/active/api_resources.php/method/mynode
?key=YOUR_API_KEY_HERE
&startTime=START_TIME[Optional]
&endTime=END_TIME[Optional]en
ウェブサイトは、画像に示されているように入力 (タイムスタンプ) を取得します。
私のウィンドウのスクリーンショット
今私のコードはここにあります:
class Algorithm extends JFrame implements ActionListener {
private static String ENDPOINT =
"http://wisekar.iitd.ernet.in/active/api_"
+ "resources.php/method/mynode.json?key=api_key";
Algorithm() {
// label1 = new JLabel();.....
panel = new JPanel(new GridLayout(5, 2));
//adding in panel label1,text1 ...
add(panel, BorderLayout.CENTER);
SUBMIT.addActionListener(this);
setTitle("Optimal Travel Route");
}
public void actionPerformed(ActionEvent ae) {
try {
//String value1 = text1.getText();..
URL url = new URL(ENDPOINT + "&datasetId=" + value3
+ "&startTime=" + value1 + "&endTime=" + value2);
System.out.println(url);
HttpURLConnection httpCon;
httpCon = (HttpURLConnection) url.openConnection();
httpCon.setDoInput(true);
System.out.println(httpCon.getResponseCode());
System.out.println(httpCon.getResponseMessage());
BufferedReader in = new BufferedReader(new InputStreamReader(
httpCon.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
} catch (IOException ex) {
Logger.getLogger(Algorithm.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
class AlgorithmDemo {
public static void main(String arg[]) {
try {
Algorithm frame = new Algorithm();
frame.setSize(450, 200);
frame.setVisible(true);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}
私はすべてを試しました。私はそれをコメントしました。このコードを使用すると、生成された URL をブラウザーに入力するとノードが取得されますが、印刷時にコンソールに結果が表示されません。私のコードで何が間違っていますか? 日付と時刻を GET に渡す方法を教えてください。助けてください。データ セット ID のみを入力すると、そのデータ セット ID のすべてのノードが表示されます。私によると、タイムスタンプを渡す際にいくつかの問題があります。