Today I have been learning facebook java api. Although I have successfully created a “hello world” app, I had a hard time to figure out how to show the grant access page. I need user to grant access to the application, so I can retrieve user data. I know I just need to redirect the page, but I tried req.sendRequest(URL) does not seem working somehow.. and I found out I set the wrong content type.. opp! stupid me! but instead of using sendRequest, I used fb tag:
String loginPage = "http://www.facebook.com/login.php?api_key="+"b76ad1939053......895b81b3"+"&v=1.0&canvas=true";
...
sessionKey = req.getParameter(FacebookParam.SESSION_KEY.toString());
...
if (sessionKey == null) { // if user is not login or user does not add the application
resp.getWriter().println("<fb:redirect url=" + loginPage + "/>");
}
else {
...
}
Now I can try to learn more stuff from it… waste me all day…. stupid me…