我可以在与 CURL 没有问题的情况下拉动用户状态, 但当我连接到 Java 时, xml 就会被截断, 我的剖析器想哭。 我用小用户测试它, 这样它就不会窒息数据或任何东西 。
public void getRuserHx(){
System.out.println("Getting user status history...");
String https_url = "https://twitter.com/statuses/user_timeline/" + idS.rootUser + ".xml?count=100&page=[1-32]";
URL url;
try {
url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
con.setRequestMethod("GET");
con.setReadTimeout(15*1000);
//dump all the content into an xml file
print_content(con);
时 时
catch (MalformedURLException e) {
e.printStackTrace();
时 时
catch (IOException e) {
e.printStackTrace();
时 时
System.out.println("Finished downloading user status history.");
时 时
private void print_content(HttpsURLConnection con){
if(con!=null){
try {
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
File userHx = new File("/" + idS.rootUser + "Hx.xml");
PrintWriter out = new PrintWriter(idS.hoopoeData + userHx);
String input;
while ((input = br.readLine()) != null){
out.println(input);
时 时
br.close();
时 时
catch (IOException e) {
e.printStackTrace();
时 时
时 时
这个请求不需要认证。 抱歉我的丑陋代码。 我的教授说输入并不重要, 所以我的I/O是一个火车事故。