我创建了一个代码,用于检查用户是否已登录Facebook。这就是它的样子:
=
接下来,我解析Json,检查它是否为URL url = new URL("https://graph.facebook.com/me?access_token=" + this.fb_token);
System.out.println("Attempting to open connection");
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
int responseCode = conn.getResponseCode();
System.out.println(responseCode);
BufferedReader reader;
if(responseCode != 200) {
reader = new BufferedReader(new InputStreamReader(conn.getErrorStream(), "UTF-8"));
}
else{
reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
}
String json = reader.readLine();
reader.close();
conn.disconnect();
return json;
或error
代码并记录用户。
我的问题是: data
是否足够检查? Facebook是否可以在验证成功的情况下返回不同的状态代码?