Facebook graph api JavaHTTPGET请求到facebook。错误的请求
我编写了一些代码,使用一个有效的浏览器控件从客户端与facebook进行交互 我正在尝试运行一个servlet应用程序,以便与facebook进行身份验证。servlet重用我在客户机中使用的类 url_conn的值为: {my id string}&client_secret={字母数字字符串secret}&fb_交换_令牌={非常长的字母数字字符串}&grant_type=fb_交换_令牌 . 我已经删除了使用{}的实际值 这是密码。怎么了?请提供一些指导。谢谢Facebook graph api JavaHTTPGET请求到facebook。错误的请求,facebook-graph-api,jakarta-ee,tomcat,servlets,bad-request,Facebook Graph Api,Jakarta Ee,Tomcat,Servlets,Bad Request,我编写了一些代码,使用一个有效的浏览器控件从客户端与facebook进行交互 我正在尝试运行一个servlet应用程序,以便与facebook进行身份验证。servlet重用我在客户机中使用的类 url_conn的值为: {my id string}&client_secret={字母数字字符串secret}&fb_交换_令牌={非常长的字母数字字符串}&grant_type=fb_交换_令牌 . 我已经删除了使用{}的实际值 这是密码。怎么了?请提供一些指导。谢谢 try{
try{
System.out.println("Attempting to open connection");
conn = (HttpURLConnection) (url_conn.openConnection());
if (conn.getResponseCode() != 200) {
System.out.println("Throwing IO Exception Successful on " + url_conn.toString());
throw new IOException(conn.getResponseMessage());
}
// conn.setRequestProperty("Accept-Charset","UTF-8");
System.out.println("Attempt Successful");
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
String json = reader.readLine();
JsonReader MyJsonReader = Json.createReader(reader);
JsonObject jsonObject = MyJsonReader.readObject();
MyJsonReader.close();
reader.close();
sb = sb.append(jsonObject.toString());
}
catch(Exception e)
{
System.out.println("Error From The FileCounter Class " + e.getMessage());
e.printStackTrace();
}
conn.disconnect();
}
Facebook只能通过https访问(s代表安全,基本上就是http over SSL/TLS)。尝试使用java的HttpsURLConnection类而不是HttpURLConnection类()。例如:
HttpsURLConnection con=(HttpsURLConnection)url.openConnection()代码>非常感谢你。另外,我不小心把钥匙夹坏了。现在已经修好了