這裏是我的API密鑰:7b5e30851a9285340e78c201c4e4ab99如何連接到TMDB API
,我試圖連接到TMDB API:這裏是我的代碼:
package movieDBapiconnnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class connection {
public static void main(String[] args) throws Exception{
URL url = new URL("http://api.themoviedb.org/3/movie/550?api_key=7b5e30851a9285340e78c201c4e4ab99/3/movie/550");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod("GET");
con.setRequestProperty("Content-Type", "application/json");
BufferedReader br = new BufferedReader(new InputStreamReader((con.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
}
}
但它總是顯示我的錯誤:螺紋
異常 「主」 產生java.io.IOException:在MOVI http://api.themoviedb.org/3/movie/550?api_key=7b5e30851a9285340e78c201c4e4ab99/3/movie/550 在sun.net.www.protocol.http.HttpURLConnection.getInputStream(來源不明) :服務器返回的HTTP響應代碼:401網址eDBapiconnnection.connection.main(connection.java:17)
「這是我的API密鑰:blech」你爲什麼會*給出你的API密鑰?你也可以免費發放你的房屋鑰匙和密碼。 – hexafraction
@hexafraction對我來說並不重要,問題在於連接問題,你有什麼想法嗎? – Jusleong