且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从我的java servlet访问重定向的url?

更新时间:2023-12-04 16:13:34

你应该能够做一些类似 String code = req.getParameter(code);


Hey guys, I've started doing some work on servlets, and I need to implement a facebook login for one of my projects. I created a dummy app on facebook, and I am using restfb for this. First I redirect the user to

https://graph.facebook.com/oauth/authorize?client_id=[MY_APP_ID]&display=page&redirect_uri=[MY_WEBPAGE]&scope=[PERMISSIONS_MY_APP_IS_ASKING_FOR]

to get permission, and if the user clicks allow, then facebook redirects the user to [MY_WEBPAGE]/?code=XXXX, and I need to be able to have access to whatever comes after code. How would I fetch the part after "code" in a servlet?

Thanks

You should be able to do something like String code = req.getParameter("code");