Boa!!
To tentando criar um aplicativo facebook utilizando Servlet e a api facebook-java-3. A session só retorna null, tentei muito antes de pedir ajuda. Se alguém puder ajudar, abaixo segue o código.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String FB_APP_ADD_URL = "http://www.facebook.com/add.php?api_key=";
String FB_API_KEY = "314560615266184";
String FB_SECRET_KEY = "0ec62e7f98d8186c10ce7ec59d64bc96";
HttpSession session = request.getSession(true);
System.out.println(session.toString());
String sessionKey = (String) session.getAttribute("restSearchAppSession");
System.out.println(sessionKey);
String authToken = request.getParameter("auth_token");
System.out.println(authToken);
FacebookJsonRestClient client = null;
if (sessionKey != null) {
client = new FacebookJsonRestClient(FB_API_KEY, FB_SECRET_KEY, sessionKey);
System.out.print("1");
} else if (authToken != null) {
client = new FacebookJsonRestClient(FB_API_KEY, FB_SECRET_KEY);
System.out.print("2");
try {
System.out.print("3");
sessionKey = client.auth_getSession(authToken);
session.setAttribute("restSearchAppSession", sessionKey);
} catch (Exception e) {
System.out.print("4");
e.printStackTrace();
}
} else {
System.out.print("5");
response.sendRedirect(FB_APP_ADD_URL+FB_API_KEY);
return;
}
System.out.print("6");
if (getFacebookInfo(request, client)) {
request.getRequestDispatcher(
"/main_page.jsp").forward(request, response);
System.out.print("entrou");
}
Obrigado!