当我使用HttpURLConnection请求php文件时如下
link = "http://mastermaster.0fees.us/signup.php";
URL url = new URL(link);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
我收到一个json文件,其末尾有一条消息告诉此网站需要Javascript才能运行,请在浏览器中启用Javascript或使用带有Javascript的浏览器
当我在我的笔记本电脑中测试链接时,它工作正常,所以我该怎么做,完整的请求代码如下;
try {
data = "?fullname=" + URLEncoder.encode(fullName, "UTF-8");
data += "&username=" + URLEncoder.encode(userName, "UTF-8");
data += "&password=" + URLEncoder.encode(passWord, "UTF-8");
data += "&phonenumber=" + URLEncoder.encode(phoneNumber, "UTF-8");
data += "&emailaddress=" + URLEncoder.encode(emailAddress, "UTF-8");
link = "http://mastermaster.0fees.us/signup.php"+data;
URL url = new URL(link);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setConnectTimeout(15 * 1000);
con.setDoOutput(true);
bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
result = bufferedReader.readLine();
return result;
} catch (Exception e) {
return new String("Exception: " + e.getMessage());
}
}
答案 0 :(得分:0)
您需要从之前的请求中获取__test
Cookie,然后将其传递给下一个请求。
我在PHP中做了一个快速测试并且它有效:
{"query_result":"done"}