根据这个page我正在设置url以获取access_token。下面是我的redirectUri字符串和urlForAccessToken字符串。
String redirectUri = "http://xxxx.mine.nu:8081/myfacebookapp/myfbapp";
String urlForAccessToken = "https://www.facebook.com/dialog/oauth?client_id="+apiKey+"&redirect_uri="+redirectUri+"&scope=email,read_stream";
我在Facebook中的网站网址和应用领域(我们设置了应用的基础知识)是:
site URL: http://xxxx.mine.nu:8081/myfacebookapp/myfbapp
App domain: xxxx.mine.nu
现在,问题是我在做一个response.sendRedirect(urlForAccessToken);从servlet我得到以下错误:
The web page at http://xxxx.mine.nu:8081/myfacebookapp/myfbapp?code=xxx#base_domain=xxxx.mine.nu
has resulted in too many redirects. Clearing your cookies for this site
or allowing third-party cookies may fix the problem. If not, it is possibly
a server configuration issue and not a problem with your computer.
我清除了cookie但没有成功。
有人会指导我做错了什么。我只是想获取访问令牌,并希望访问Facebook用户的基本数据和扩展数据。
我的平台是Java,我使用restFB与图形API进行通信。
下面的是我的servlet代码:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<br><h4>We are getting Facebook data</h4>");
response.sendRedirect(urlForAccessToken);
String access_token = (String)request.getParameter("access_token");
out.println("<br>code: " + code);
try{
FacebookClient facebookClient = new DefaultFacebookClient(access_token);
//user = facebookClient.fetchObject("xxxxxxxxxxxx", User.class);
out.println("<br>User: " + user.getName());
}catch(FacebookException e){
e.printStackTrace();
}
}
赞赏早期回应。